[REBOL] Re: Math overflow
From: joel:neely:fedex at: 6-Jul-2003 7:15
It's all in the types.
Ashley Truter wrote:
> I vaguely remember this coming up before, but can anyone explain
> why the first expression fails and the second succeeds:
>>> 2133147400 + 26604769
> ** Math Error: Math or number overflow
> ** Near: 2133147400 + 26604769
>>> 9999999999 + 99999999
> == 10099999998
Take a look at this:
>> type? 2133147400
>> type? 26604769
>> type? 9999999999
>> type? 99999999
The behavior of the addition operator changes based on the type
of the left-hand argument.
The first case attempts to use integer addition and overflows
the valid range for integer values. The second case uses
floating-point addition, as the left-hand value (silently) is
viewed as floating-point, and therefore does *not* overflow
the floating-point range.