Re: bignum incompatible with looks_like_number() ???



In article <468603ae$0$14626$afc38c87@xxxxxxxxxxxxxxxxxxxx>,
"Sisyphus" <sisyphus1@xxxxxxxxxxxxxxxxx> wrote:

Please give some examples of how you imagine bignum is SUPPOSED to be
used.

Please include $x = 2**512+0.0 in your examples.



Consider Foo.pm:
-------------------------------
package Foo;
use Scalar::Util qw(looks_like_number);

sub my_foo {
my $out = $_[0] + 1;
return $out;
}

sub my_bar {
die "Not a number" unless(looks_like_number($_[0]));
my $out = $_[0] + 1;
return $out;
}

1;
-------------------------------

And try.pl:
-------------------------------
use strict;
use warnings;
use bignum;
use Foo;

my $x = (2 ** 512) + 0.0;
print ref($x), "\n";
print $x, "\n";
print Foo::my_foo(2 ** 512), "\n";
print Foo::my_bar(2 ** 512), "\n";
-------------------------------

when I run the above script (try.pl) I get:
----------------------------------
Math::BigInt
134078079299425970995740249982058461274793658205923933777235614437217640300735
46
976801874298166903427690031858186486050853753882811946569946433649006084096
134078079299425970995740249982058461274793658205923933777235614437217640300735
46
976801874298166903427690031858186486050853753882811946569946433649006084097
Not a number at Foo.pm line 10.
----------------------------------

Leaving Foo.pm completely untouched, and changing try.pl to:

use strict;
use warnings;
#use bignum;
use Foo;

my $x =42;

print $x, "\n";
print Foo::my_foo(42), "\n";
print Foo::my_bar(42), "\n";

yields:
perl -I~ ~/test.pl
42
43
43

But removing the comment marker from in front of bignum causes the death.

See my subsequent post.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
.



Relevant Pages