Re: bignum incompatible with looks_like_number() ???
- From: "Sisyphus" <sisyphus1@xxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Jun 2007 12:52:52 +1000
"C B" <cb0@xxxxxxx> wrote in message news:cb0-1D13A6.09170627062007@xxxxxxxxxxxxxxxxxxxxx
..
..
my call looks like this:
$result = xirr(%HashOfDatesAndCashflows, precision => 0.000001);
This works fine, except that I'm getting answers that are a little off
numerically.
That would probably be because decimal fractions like 0.000001 cannot be represented with complete accuracy in the internal binary form that computers use (irrespective of the number of bits of precision that have been allocated).
So, in my main .pl file, I added the line:
use bignum;
Which resulted in an error message:
ERROR: precision is not a valid number at /Users/cb/main.pl line 189
After digging around, I discovered that Finance::Math::IRR calls
looks_like_number($x) where $x is set to the value of the precision hash
key.
Sure enough, the debugger reveals that I'm calling xirr with:
'precision' => bless( {
'_m' => [1],
'_es' => '-',
'_e' => [6],
'sign' => '+'
}, 'Math::BigFloat' )
which SHOULD pass the looks_like_number test, but it doesn't.
No - it's a Math::BigFloat object, which looks nothing like a number to (both me and) Scalar::Util::looks_like_number().
I guess the basic issue is that Math::Finance::IRR is not built to handle Math::BigFloat objects.
Cheers,
Rob
.
- Follow-Ups:
- References:
- Prev by Date: bignum incompatible with looks_like_number() ???
- Next by Date: Re: XPath to Line Number?
- Previous by thread: bignum incompatible with looks_like_number() ???
- Next by thread: Re: bignum incompatible with looks_like_number() ???
- Index(es):
Relevant Pages
|