Skip Menu |

This queue is for tickets about the version CPAN distribution.

Report information
The Basics
Id: 74724
Status: rejected
Priority: 0/
Queue: version

People
Owner: Nobody in particular
Requestors: dcantrell [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.95
Fixed in: (no value)



Subject: version.pm truncates long version numbers
Presented with a version number such as 1.20120129233212, version.pm truncates this to 1.201201292. I have verified that this also affects 0.96, which RT's form doesn't know about.
This isn't version.pm's fault, but rather the fault of Perl's handling of floating point numbers. Each element of a version object is a full integer, but version.pm relies on Perl's own handling of floating point numbers if you use a bare (i.e. unquoted) number. That decimal number is too large to represent as a floating point number on your machine. If you quote it, however, it works fine: $ perl -Mversion -e 'my $v = version->new("1.20120129233212"); print $v' 1.20120129233212
On Tue Feb 07 06:33:24 2012, JPEACOCK wrote: Show quoted text
> This isn't version.pm's fault, but rather the fault of Perl's handling > of floating point numbers. Each element of a version object is a full > integer, but version.pm relies on Perl's own handling of floating
point Show quoted text
> numbers if you use a bare (i.e. unquoted) number. That decimal number > is too large to represent as a floating point number on your machine. > > If you quote it, however, it works fine: > > $ perl -Mversion -e 'my $v = version->new("1.20120129233212"); print
$v' Show quoted text
> 1.20120129233212
My perl handles that floating point number just fine: $ perl -e 'print 1.20120129233212' 1.20120129233212 $ perl -e 'print 1.20120129233212 + 0.00000000000001' 1.20120129233213
On Wed Feb 08 09:42:14 2012, DCANTRELL wrote: Show quoted text
> My perl handles that floating point number just fine: > > $ perl -e 'print 1.20120129233212' > 1.20120129233212 > $ perl -e 'print 1.20120129233212 + 0.00000000000001' > 1.20120129233213
Yes, _your_ Perl can handle that. Someone with a different config may not be able to. The version.pm code has to work with different configurations so I limit the absolute number of decimal places for pure floating point values (this goes back over 9 years). Floating point notation _will_ be unable to consistently maintain all digits at some point. As I said, quoting the value will guarantee that what you type (or generate) as a version will be translated to a version object consistently, without loss, no matter how many decimals you use.