|Perl: the Markov chain saw|
Re: Bignum breaks Time::Local? (constants)by tye (Cardinal)
|on Nov 05, 2012 at 23:34 UTC||Need Help??|
What I *think* (after some testing) is going on is that the Math::BigInt and Math::Bigfloat overload the arithmetic operators, which breaks timegm().
No, overloading of operators is based only on the arguments given to them. But 'use bignum;' overloads numeric constants. So, for example:
And Math::BigInt might not be careful enough to have Math::BigInt->new(0) act enough like just plain 0 for timegm()'s usage (not surprisingly).
Is this expected behavior and/or documented anywhere?
It sounds like you probably read the first sentence of the bignum documentation. Perhaps you failed to go on to read the second sentence.
This makes bignum.pm a cute demonstration that can be convenient for a one-liner. Otherwise, you should just use Math::BigInt and/or Math::BigFloat directly, so you can avoid making every single time you use a numeric constant magically turn into a complex object that infects the results of any computations that touch it.
Most of the time you only even need to call Math::BigInt->new() once, so a wrapper like bignum.pm seems of dubious benefit. bignum.pm should probably come with a big warning like "This transforms simple-looking Perl code into something very different and can easily break code".