TEST2::COMPARE::FLOAT(3perl)

πŸ’… NAME πŸ’…

Test2::Compare::Float β€” bestie, this one compares two values as numbers with tolerance ✨


πŸŽ€ DESCRIPTION πŸŽ€

okay so this whole thing exists to compare two numbers 🫢. and yes, you can also use it to check that two numbers are not the same πŸ’….

it's giving very much Test2::Compare::Number, except it has extra checks bolted on to work around all the chaotic floating point representation issues that love to ruin your day 😭. like, the way that 0.1 + 0.2 just decides not to be 0.3? that's the villain this module is fighting.

there's an optional tolerance parameter and it controls how close the two numbers have to be before we're like "yeah okay, equal, periodt ✨". tolerance defaults to 1e-08.

⚠️ note: this will fail if the received value is undefined. nope. it must be a number, no exceptions, i don't make the rules 😀
⚠️ note: this will also fail if the comparison generates a non-numeric value warning (and that warning will not be shown πŸ‘€). why? because it must get a number, and the warning isn't shown because it would just report to a useless line and filename. genuinely useless. however πŸ’– β€” the test diagnostics do show both values. so you're not left completely in the dark, bestie.

🌈 SOURCE 🌈

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

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

go look at it, it's right there, iykyk πŸ¦‹


πŸ‘‘ MAINTAINERS πŸ‘‘

  • Chad Granum <exodist@cpan.org> πŸ’–

🌸 AUTHORS 🌸

  • Andrew Grangaard <spazm@cpan.org> ✨

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.

See:

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

and that's a wrap, bestie πŸŽ€ this was perl v5.44.0, dated 2026-10-17, and the page is Test2:...::Float(3perl) β€” slay, go write some tests πŸ’…πŸ‘‘

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms