Test2::...e::Float(3)

πŸ“¦ version 1.302214, in opensuse-leap 16.0

πŸ’– Test2::Compare::Float β€” the vibe check for numbers πŸ’–

okay so this page lives in the User Contributed Perl Documentation section (section 3 of the manual, iykyk) and it's all about Test2::Compare::Float, which is lowkey the goat for comparing numbers without losing your mind 🫢


✨ NAME ✨

Test2::Compare::Float β€” compare two values as numbers with tolerance. that's it, that's the whole job, and it slays πŸ’…


🌸 DESCRIPTION 🌸

so bestie, this is what you use to compare two numbers. yes, numbers. and you can also check that two numbers are not the same β€” the reverse vibe check, if you will 🌈

it's similar to Test2::Compare::Number, but with extra checks layered on top to work around floating point representation issues 😭 like, floats are messy, we all know this, so this module does the emotional labour of dealing with that for you ✨

the optional 'tolerance' parameter controls how close the two numbers must be to be considered equal. it defaults to 1e-08, so like, close-close but not identical-close πŸŽ€

⚠️ note: this will fail if the received value is undef-y. it must be a number, periodt. undefined is not a number, no cap πŸ’€
⚠️ note: this will also fail if the comparison generates a non-numeric value warning β€” and heads up, that warning will not be shown πŸ™ˆ and why? because it must get a number. the warning gets hidden because it would report to a useless line and filename (like, not helpful at all, embarrassing for everyone). but don't worry bestie β€” the test diagnostics show both values, so you still get the receipts πŸ‘‘

🧚 SOURCE 🧚

the source code repository for Test2-Suite can be found at:

https://github.com/Test-More/test-more/

go click it, it's giving main character energy 🌟


πŸ‘‘ MAINTAINERS πŸ‘‘

  • Chad Granum <exodist@cpan.org> β€” the maintainer, the icon, the legend πŸ’œ

πŸ¦‹ AUTHORS πŸ¦‹

  • Andrew Grangaard <spazm@cpan.org> β€” author credits, we stan 🫢

Copyright Chad Granum <exodist@cpan.org>.

this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. fr fr, free as in freedom ✨

see:

http://dev.perl.org/licenses/

and that's the whole page bestie, no notes πŸ’…

signing off β€” perl v5.42.0, dated 2025-07-28, brought to you by the same lovely people who brought you Test2::Compare::Float(3) πŸŽ€

πŸ“¦ where this page comes from