Skip Menu |

This queue is for tickets about the Math-BigInt CPAN distribution.

Report information
The Basics
Id: 61778
Status: resolved
Worked: 16 hours (960 min)
Priority: 0/
Queue: Math-BigInt

People
Owner: Nobody in particular
Requestors: peter.jakobsen [...] amd.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.96
Fixed in: (no value)



Subject: Number starting with '_' (0b_1111) is recognized as NaN
Numbers that begin with an '_', which is a valid character when embedded between other alphanumerics(hex) produce NaN. pjakobse@MHDCL28764 ~ $ perl -e "use Math::BigInt; print new Math::BigInt('0b_1111')->as_hex;" NaN pjakobse@MHDCL28764 ~ $ perl -e "use Math::BigInt; print new Math::BigInt('0b1111')->as_hex;" 0xf $ perl -v This is perl, v5.10.1 (*) built for i686-cygwin-thread-multi-64int Math::BigInt v 1.96
I think the most consistent would be if Math::BigInt and Math::BigFloat accepted the same input as Perl itself. Perl allows underscores in numbers almost everywhere except at the beginning of the number, but a warning is printed ("Misplaced _ in number") is printed if an underscore is not between digits of there are multiple underscores following each other. Here are some variants that are accepted without a warning: "0b1_1", "1_2", "1_2.3_4", "1_2.3_4e5_6". Here are some variants that are accepted, but gives the mentioned warning: "0b_11", "0b11_", "0b1__1", "12_", "1__2", "12_.34", "12_._34_e_56_". Coincidentally, I noticed this some time ago and started fixing it. It was more difficult that I expected, since the code is terribly messy. The code is highly optimized for speed rather than clarity and maintainability (contrary to what is mentioned in the file "GOALS"), and there are hardly any comments mentioning why things are done the way they are. After – I guess – two days of efficient work, I understand how it all works together and fixed the code. I added some comments and also rewrote some code (_split() is now both faster and easier to understand). I also had to edit some tests since some input used to return NaN, but now returns a number. I have attached the patch file. All the tests pass. I really hope this gets through. It was a lot of work.
Subject: Math-BigInt-1.96-patch-id-61778.txt

Message body is not shown because it is too large.

From: peter.jakobsen [...] amd.com
The patch looks good to me. Thanks. On Tue Oct 05 15:38:22 2010, pjacklam wrote: Show quoted text
> I think the most consistent would be if Math::BigInt and Math::BigFloat > accepted the same input as Perl itself. Perl allows underscores in > numbers almost everywhere except at the beginning of the number, but a > warning is printed ("Misplaced _ in number") is printed if an underscore > is not between digits of there are multiple underscores following each > other. > > Here are some variants that are accepted without a warning: "0b1_1", > "1_2", "1_2.3_4", "1_2.3_4e5_6". > > Here are some variants that are accepted, but gives the mentioned > warning: "0b_11", "0b11_", "0b1__1", "12_", "1__2", "12_.34", > "12_._34_e_56_". > > Coincidentally, I noticed this some time ago and started fixing it. It > was more difficult that I expected, since the code is terribly messy. > The code is highly optimized for speed rather than clarity and > maintainability (contrary to what is mentioned in the file "GOALS"), and > there are hardly any comments mentioning why things are done the way > they are. After – I guess – two days of efficient work, I understand how > it all works together and fixed the code. I added some comments and also > rewrote some code (_split() is now both faster and easier to > understand). I also had to edit some tests since some input used to > return NaN, but now returns a number. > > I have attached the patch file. All the tests pass. I really hope this > gets through. It was a lot of work.
Fixed in Math::BigInt 1.992.