Beloved Brethren and Sistren:
I am having a difficulty that is sorely trying me. I am trying to use the BigFloat module for various calculations. My code is thus:
#!/usr/bin/perl -w use warnings; use strict; use diagnostics; use Math::BigFloat; my $float=Math::BigFloat->new(2.0); $float->bsqrt(); print "\$float is a:\t" . ref($float) . "\n"; my $int = $float->as_int(); print "\$int is a:\t" .ref($int) . "\n"; print "\$float\t$float\n\$int:\t$int\n";
According to the documents, the as_int() method should return an BigInt value. However, as you can see from this output, it does not:
$float is a: Math::BigFloat $int is a: Math::BigFloat $float 1.41421356237309504880168872420969807857 $int: 1.41421356237309504880168872420969807857
The documentation for this module says:
$x->as_int(); # return $x as BigIntWhat am I doing wrong? I assume I've made some assumption that isn't true, but I haven't been able to find anything in the documentation that explains this mysterious behavior. I cannot believe that this is a bug... any help would be appreciated. Thank you.
Update: Thanks, Zaxo. That worked beautifully...
In reply to Unexpected behavior of a method in BigFloat by spiritway
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |