Skip Menu |

This queue is for tickets about the NetAddr-IP CPAN distribution.

Report information
The Basics
Id: 71781
Status: resolved
Worked: 24 hours (1440 min)
Priority: 0/
Queue: NetAddr-IP

People
Owner: Nobody in particular
Requestors: ribasushi [...] leporine.io
Cc:
AdminCc:

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



Subject: Calls to ->numeric on IPV6 objects should return Math::BigInts
Without adjustments to ->numeric, the following happens, which is far far from desired (there's no way to support 128-bit numbers natively in perl) perl -MNetAddr::IP -E 'say (NetAddr::IP->new("2001::1")->numeric <=> NetAddr::IP->new("2001::3")->numeric )' 0 Interestingly with just nummification things behave correctly: perl -MNetAddr::IP -E 'say (NetAddr::IP->new("2001::1") <=> NetAddr::IP->new("2001::3") )' -1 Cheers
A good deal of effort went into release 4.00 in June of 2006 to eliminate the need for Math::BigInt -- It is a nice package but does not run on older versions of perl and back then was buggy. NetAdd::IP will accomodate 128 bit decimal numbers as strings but will no convert 128 bit vectors back into numbers. There is nothing you could do with them anyway on a platform that does not support BIG numbers. NetAddr::IP->numeric returns a bcd string for large numbers. The comparison operator <=> is a PERL operator that works on numbers that the OS and the version of perl can manipulate. That does not include large bcd strings. NetAddr::IP can dealt with these because it has its own 128 bit arithmetic package. So, for the few people that like to use big bcd numbers or those that for some reason decide to use NetAddr::IP in conjunction with Math::BigInt the capability has been in NetAddr::IP since June of 2006 when 4.001 was release. The new release, 4.049 has many no so visible enhancements that make extensions of IPv6 easier to deal with. Best regards, Michael On Wed Oct 19 13:24:32 2011, RIBASUSHI wrote: Show quoted text
> Without adjustments to ->numeric, the following happens, which is far > far from desired (there's no way to support 128-bit numbers natively in > perl) > > perl -MNetAddr::IP -E 'say (NetAddr::IP->new("2001::1")->numeric <=> > NetAddr::IP->new("2001::3")->numeric )' > 0 > > Interestingly with just nummification things behave correctly: > > perl -MNetAddr::IP -E 'say (NetAddr::IP->new("2001::1") <=> > NetAddr::IP->new("2001::3") )' > -1 > > Cheers
On Thu Oct 20 01:55:57 2011, MIKER wrote: Show quoted text
> A good deal of effort went into release 4.00 in June of 2006 to > eliminate the need for Math::BigInt -- It is a nice package but does not > run on older versions of perl and back then was buggy.
I am finding it hard to comprehend the above statement. Could you please explain your logic in terms of corelist: rabbit@Dungeon:~$ corelist -a Math::BigInt Math::BigInt was first released with perl 5 5 undef 5.001 undef 5.002 undef 5.00307 undef 5.004 undef 5.00405 undef 5.005 undef 5.00503 undef 5.00504 undef v5.6.0 undef v5.6.1 0.01 v5.6.2 0.01 v5.7.3 1.54 v5.8.0 1.60 v5.8.1 1.66 v5.8.2 1.66 v5.8.3 1.68 v5.8.4 1.70 v5.8.5 1.70 v5.8.6 1.73 v5.8.7 1.77 v5.8.8 1.77 v5.8.9 1.89 v5.9.0 1.66 v5.9.1 1.70 v5.9.2 1.75 v5.9.3 1.77 v5.9.4 1.77 v5.9.5 1.87 v5.10.0 1.88 v5.10.1 1.89 v5.11.0 1.89_01 v5.11.1 1.89_01 v5.11.2 1.89_01 v5.11.3 1.89_01 v5.11.4 1.89_01 v5.11.5 1.89_01 v5.12.0 1.89_01 v5.12.1 1.89_01 v5.12.2 1.89_01 v5.12.3 1.89_01 v5.13.0 1.89_01 v5.13.1 1.89_01 v5.13.2 1.89_01 v5.13.3 1.89_01 v5.13.4 1.89_01 v5.13.5 1.95 v5.13.6 1.97 v5.13.7 1.99_01 v5.13.8 1.99_02 v5.13.9 1.99_03 v5.13.10 1.992 v5.13.11 1.994 v5.14.0 1.994 v5.14.1 1.994
On Thu Oct 20 09:37:14 2011, RIBASUSHI wrote: Show quoted text
> On Thu Oct 20 01:55:57 2011, MIKER wrote:
> > A good deal of effort went into release 4.00 in June of 2006 to > > eliminate the need for Math::BigInt -- It is a nice package but does not > > run on older versions of perl and back then was buggy.
> > I am finding it hard to comprehend the above statement. Could you please > explain your logic in terms of corelist: > > rabbit@Dungeon:~$ corelist -a Math::BigInt > > Math::BigInt was first released with perl 5 > 5 undef > 5.001 undef > 5.002 undef > 5.00307 undef > 5.004 undef > 5.00405 undef > 5.005 undef > 5.00503 undef > 5.00504 undef > v5.6.0 undef > v5.6.1 0.01 > v5.6.2 0.01 > v5.7.3 1.54 > v5.8.0 1.60 > v5.8.1 1.66 > v5.8.2 1.66 > v5.8.3 1.68 > v5.8.4 1.70 > v5.8.5 1.70 > v5.8.6 1.73 > v5.8.7 1.77 > v5.8.8 1.77 > v5.8.9 1.89 > v5.9.0 1.66 > v5.9.1 1.70 > v5.9.2 1.75 > v5.9.3 1.77 > v5.9.4 1.77 > v5.9.5 1.87 > v5.10.0 1.88 > v5.10.1 1.89 > v5.11.0 1.89_01 > v5.11.1 1.89_01 > v5.11.2 1.89_01 > v5.11.3 1.89_01 > v5.11.4 1.89_01 > v5.11.5 1.89_01 > v5.12.0 1.89_01 > v5.12.1 1.89_01 > v5.12.2 1.89_01 > v5.12.3 1.89_01 > v5.13.0 1.89_01 > v5.13.1 1.89_01 > v5.13.2 1.89_01 > v5.13.3 1.89_01 > v5.13.4 1.89_01 > v5.13.5 1.95 > v5.13.6 1.97 > v5.13.7 1.99_01 > v5.13.8 1.99_02 > v5.13.9 1.99_03 > v5.13.10 1.992 > v5.13.11 1.994 > v5.14.0 1.994 > v5.14.1 1.994 > >
The difficulty is/was that Math::BigInt is a C program that did/does not compile on many systems including common Linux distro's that are/were available at the time -- note the undef's on your list. The test case you show is easily fixed by changing one term and will work in all cases. perl -MNetAddr::IP -E 'say (NetAddr::IP->new("2001::1") eq NetAddr::IP->new("2001::3") )' and if you print $ip->numeric(),"\n" you will get the "number" representing the ip address as a decimal string to do with as you wish. This is not an issue with NetAddr::IP, it is an issue with perl's inability to represent very large numbers without the help of something like Math::BigInt. NetAddr::IP works whether or not perl can handle the size of the number. If Math::BigInt is available then one can easily say... my $num = Math::BigInt->new($ip->numeric); hmmm... this is not a numeric conversion issue but one of representing the object "ip" in the case of NetAddr::IP and "num" in the case of Math::BigInt ---- time passes, 30 minutes or so I will release version 4.050 shortly that has the method $ip->bigint which returns a Math::BigInt number NetAddr::IP will still not use or require the Math::BigInt to be installed but will always return the Math::BigInt representation from the method $ip->bigint. NetAddr::IP will also accept Math::BigInt numbers to convert to IP addresses. Will take a few days or so. You made me think about this a bit, thanks. Michael
On Thu Oct 20 14:36:32 2011, MIKER wrote: Show quoted text
> On Thu Oct 20 09:37:14 2011, RIBASUSHI wrote:
> > On Thu Oct 20 01:55:57 2011, MIKER wrote:
> > > A good deal of effort went into release 4.00 in June of 2006 to > > > eliminate the need for Math::BigInt -- It is a nice package but
does not Show quoted text
> > > run on older versions of perl and back then was buggy.
> > > > I am finding it hard to comprehend the above statement. Could you please > > explain your logic in terms of corelist: > > > > rabbit@Dungeon:~$ corelist -a Math::BigInt > > > > Math::BigInt was first released with perl 5 > > 5 undef > > 5.001 undef > > 5.002 undef > > 5.00307 undef > > 5.004 undef > > 5.00405 undef > > 5.005 undef > > 5.00503 undef > > 5.00504 undef > > v5.6.0 undef > > v5.6.1 0.01 > > v5.6.2 0.01 > > v5.7.3 1.54 > > v5.8.0 1.60 > > v5.8.1 1.66 > > v5.8.2 1.66 > > v5.8.3 1.68 > > v5.8.4 1.70 > > v5.8.5 1.70 > > v5.8.6 1.73 > > v5.8.7 1.77 > > v5.8.8 1.77 > > v5.8.9 1.89 > > v5.9.0 1.66 > > v5.9.1 1.70 > > v5.9.2 1.75 > > v5.9.3 1.77 > > v5.9.4 1.77 > > v5.9.5 1.87 > > v5.10.0 1.88 > > v5.10.1 1.89 > > v5.11.0 1.89_01 > > v5.11.1 1.89_01 > > v5.11.2 1.89_01 > > v5.11.3 1.89_01 > > v5.11.4 1.89_01 > > v5.11.5 1.89_01 > > v5.12.0 1.89_01 > > v5.12.1 1.89_01 > > v5.12.2 1.89_01 > > v5.12.3 1.89_01 > > v5.13.0 1.89_01 > > v5.13.1 1.89_01 > > v5.13.2 1.89_01 > > v5.13.3 1.89_01 > > v5.13.4 1.89_01 > > v5.13.5 1.95 > > v5.13.6 1.97 > > v5.13.7 1.99_01 > > v5.13.8 1.99_02 > > v5.13.9 1.99_03 > > v5.13.10 1.992 > > v5.13.11 1.994 > > v5.14.0 1.994 > > v5.14.1 1.994 > > > >
> > The difficulty is/was that Math::BigInt is a C program that did/does not > compile on many systems including common Linux distro's that are/were > available at the time -- note the undef's on your list.
The undefs do not signify "does not ship with this perl", it merely means "before perl 5.6.2 there were *NO* versions on builtin modules". Math::BigInt is indeed available on any perl since the very ancient 5.0.0. Show quoted text
> > The test case you show is easily fixed by changing one term and will > work in all cases. > > perl -MNetAddr::IP -E 'say (NetAddr::IP->new("2001::1") eq > NetAddr::IP->new("2001::3") )' > > and if you > print $ip->numeric(),"\n" you will get the "number" representing the ip > address as a decimal string to do with as you wish. This is not an issue > with NetAddr::IP, it is an issue with perl's inability to represent very > large numbers without the help of something like Math::BigInt. > NetAddr::IP works whether or not perl can handle the size of the number. > > If Math::BigInt is available then one can easily say... > > my $num = Math::BigInt->new($ip->numeric); > > hmmm... this is not a numeric conversion issue but one of representing > the object "ip" in the case of NetAddr::IP and "num" in the case of > Math::BigInt > > ---- time passes, 30 minutes or so > > I will release version 4.050 shortly that has the method > > $ip->bigint which returns a Math::BigInt number > NetAddr::IP will still not use or require the Math::BigInt to be > installed but will always return the Math::BigInt representation from > the method $ip->bigint. NetAddr::IP will also accept Math::BigInt > numbers to convert to IP addresses. Will take a few days or so. > > You made me think about this a bit, thanks.
No, thank you for considering this :) Also note that as per my remark above you can safely assume that Math::BigInt is *always* available (unless your goal is to also support perl4).
Support for Math::BigInt incorporated into release 4.050 released to CPAN see new method $ip->bigint(); On Wed Oct 19 13:24:32 2011, RIBASUSHI wrote: Show quoted text
> Without adjustments to ->numeric, the following happens, which is far > far from desired (there's no way to support 128-bit numbers natively in > perl) > > perl -MNetAddr::IP -E 'say (NetAddr::IP->new("2001::1")->numeric <=> > NetAddr::IP->new("2001::3")->numeric )' > 0 > > Interestingly with just nummification things behave correctly: > > perl -MNetAddr::IP -E 'say (NetAddr::IP->new("2001::1") <=> > NetAddr::IP->new("2001::3") )' > -1 > > Cheers