cpan[1]> ! use CPAN::Reporter
cpan[1]> o debug Version
Options set for debugging (16384):
Version (16384)
cpan[2]> ! print CPAN::Version->vlt( $CPAN::Reporter::VERSION, 0.99 ), "\n"
Debug(Version,Version.pm,11,[Version,Version.pm,60,vcmp]): l[1.1801] r[0.99]
Debug(Version,Version.pm,18,[Version,Version.pm,60,vcmp]): l[1.1801] r[0.99]
Debug(Version,Version.pm,24,[Version,Version.pm,60,vcmp]): l[1.1801] r[0.99]
Debug(Version,Version.pm,31,[Version,Version.pm,60,vcmp]): l[1.1801] r[0.99]
3.3376107877608e-308
<Reporter::VERSION ne "undef") <=> (0.99 ne "undef"), "\n")
0
cpan[2]> ! print (("v0") cmp ("v0"), "\n")
0
cpan[2]> ! print (($CPAN::Reporter::VERSION) <=> (0.00), "\n")
1
cpan[2]> ! print (($CPAN::Reporter::VERSION) <=> (0.99), "\n")
1
cpan[2]> ! print (($CPAN::Reporter::VERSION) cmp (0.99), "\n")
1
cpan[2]> ! printf "%g\n", 0 + (1 < 0)
3.33761e-308
It looks to me as though the code is doing comparisons of floating point
and forgetting about rounding errors which always happens in floating
point arithmetic. That's why in C, for example:
double a = 0.1, b = 0.1;
if(a == b)
will always give undefined results and will nearly always be false -
when comparing two floating point numbers you must always allow for
"noise" and check that the difference is less than some small number, so
the above test should be:
if((a - b) <= 0.000000001)
I think that the author of this module has forgotten this basic principal.
-Nigel
--
Nigel Horne. Arranger, Adjudicator, Band Trainer, Composer, Tutor, Typesetter.
NJH Music, ICQ#20252325, twitter: @nigelhorne
n...@bandsman.co.uk http://www.bandsman.co.uk