Derick Rethans wrote:
> On Sun, 22 Feb 2004, Derick Rethans wrote:
>
>
>>On Sun, 22 Feb 2004, Andi Gutmans wrote:
>>
>>
>>>Huh? What platform crashes? Can you send reproducible C code?
>>
>>int main(void) {
>>    long a = -2147483648;
>>    long b = -1;
>>    long c;
>>
>>    c = a % b;
>>}
>
>
> Does anybody has a clue *why* this gives a floating point error btw?
It's generating an idivl, which gives you an exception if the (signed)
result is too large (a.k.a. integer overflow).

Did you notice your compiler warning "this decimal constant is unsigned
only in ISO C90"? ;)

+2147483648 is: 10000000 00000000 00000000 00000000.
-2147483648 is too large to be represented by a signed integer (as it
would be ~(+2147483648) + 1, which gives once again: 10000000 00000000
00000000 00000000), so the result would be too large to be represented as
a signed integer, too.

Cheers,
Michael

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to