|
Posted by Oli Filth on 11/18/92 11:41
fritz-bayer@web.de said the following on 05/03/2006 11:39:
> Tim Roberts wrote:
>>
>> PHP handles the overflow by throwing away the upper bits, leaving you with
>> only the bottom 32 bits of the converted value. Perl handles the overflow
>> by "pegging"; it returns 2^32-1, or 4,294,967,295. That value happens to
>> have all 32 bit set, so the bitwise "and" returns the second value.
>>
>> If you need to handle integers larger than 32-bits in Perl, you can use the
>> Math::BigInt module to do that.
>
> Thanks Tim! Any ideas how I could emulate the overflow, so that I get
> the same overflow behaviour in perl, maybe by writting a function for
> it?!
Why would you want to do this? Either way, you're not going to get the
"correct" answer (in terms of mathematically correct).
Your best bet would be to go with the module that Tim suggested (or the
equivalent (?) in PHP - BCMath). Alternatively, re-think your algorithm
so that it doesn't require >32-bit numbers. After all, where are these
numbers going to come from?
--
Oli
[Back to original message]
|