use Test::LimitDecimalPlaces tests => 5; # Can specify the test plan. # Equality test by default number of decimal places limit_ok(1.2345678, 1.2345678, 'Test the same floating-point values.'); # Inequality test by default number of decimal places limit_not_ok( 0.0000001, 0.0000002, 'Test different values' ); # Equality test by specified number of decimal places limit_ok_by(0.00000001, 0.000000006, 8, 'Test similar value.') ."\n"; # number of decimal places is 8 # Inequality test by specified number of decimal places limit_not_ok_by( 0.00000001, 0.00000002, 8, 'Test different values.' ); # number of decimal places is 8 # Compare arrays my @x = ( 0, 1, 0.1, 0.0000001, 0.0000001 ); my @y = ( 0, 1, 0.1, 0.0000001, 0.00000006 ); limit_ok(\@x, \@y, 'Compare arrays.'); # Set a different default number of decimal places use Test::LimitDecimalPlaces num_of_digits => 6, tests => 1; limit_ok(1.234567, 1.234566, 'Test the similar floating-point values.');
If compare floating point numbers normally, we cannot get the correct result on some environment. This module was made to solve this problem.
This module provides test functions that can compare numerical values by limiting number of decimal places. These functions are using splintf() internally to limit number of decimal places.
I think this module name is not precise and attractive. And function names are not cool and intuitive (I feel they are not grammatical in the first place. Do they make sense?).
I'm not good at English as you suspect. Please give me some advice.