Re: bignum incompatible with looks_like_number() ???
- From: C B <cb0@xxxxxxx>
- Date: Wed, 27 Jun 2007 15:02:16 +0700
In article <4681d0e6$0$8915$afc38c87@xxxxxxxxxxxxxxxxxxxx>,
"Sisyphus" <sisyphus1@xxxxxxxxxxxxxxxxx> wrote:
This works fine, except that I'm getting answers that are a little off
numerically.
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).
Yeah, that's exactly why I'm trying to use bignum -- to extend the
precision out far enough so that data representation errors are below
the radar. My boss's radar certainly notices a 500 ppm error, which is
what I'm getting from Financials::Math::IRR --- which incidentally
brags about being used and tested extensively in serious financial
environments.
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().
That answer seems so far out of line with the Perl philosophy that I'm
having trouble believing it.
Firstly, the number in Math::BigFloat format is clearly +1E-6 when you
remove the OPCODEs --- which sure looks like a number to me.
Secondly, does 40490FD0 look like a number? It's 3.14159 in floating
point hex. You can't judge a number by its numerals.
Finally, I cannot believe Larry would allow fundamental things like
bignums and looks_like_number() to be incompatible --- they are both
essentially part of the Perl distro.
If you can't trust those, what parts of Perl CAN you trust?
Is there a better answer?
CB
----== 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 =----
.
- Follow-Ups:
- Re: bignum incompatible with looks_like_number() ???
- From: Sisyphus
- Re: bignum incompatible with looks_like_number() ???
- References:
- bignum incompatible with looks_like_number() ???
- From: C B
- Re: bignum incompatible with looks_like_number() ???
- From: Sisyphus
- bignum incompatible with looks_like_number() ???
- Prev by Date: Re: XPath to Line Number?
- Next by Date: Re: bignum incompatible with looks_like_number() ???
- Previous by thread: Re: bignum incompatible with looks_like_number() ???
- Next by thread: Re: bignum incompatible with looks_like_number() ???
- Index(es):
Relevant Pages
|
|