[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Math::BigInt dislikes undefined values

I did a little experimenting in BigInt.pm V 1.997
Version 1.993 is not affected.

I narrowed it down to this attached tiny (real) patch.
Which is just commenting out a few lines of code.

A few lines below BigInt actually handles the case of a undef so I filed a


Adding a negative number to achieve subtraction works.
Another reason it seems like a bug in BigInt
For example I tracked it down to stuff like IS.pm:
$form->format_amount( $myconfig, $form->{invtotal} - $form->{paid}, 2 );

Changing it to
$form->format_amount( $myconfig, - $form->{invtotal} + $form->{paid}, 2 );
Made the error go away in stock BigInt.pm 1.997
$form->{paid} being the undef in my case I think....

If they close my bug as a wont fix then do we need if's every time we do
math in ledgersmb to make sure we are doing math on a defined?

Cheers Turtle

--- BigInt-b.pm	2012-10-12 21:55:30.102263313 -0700
+++ BigInt.pm	2012-10-12 23:25:06.926513039 -0700
@@ -2669,9 +2669,9 @@
         # Don't do anything with undefs.
-        unless (defined($a[$i])) {
-            next;
-        }
+        #unless (defined($a[$i])) {
+        #    next;
+        #}
         # Perl scalars are fed to the appropriate constructor.