[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_number2int
- From: "Brian Weed" <bw@...>
- Date: Tue, 14 Nov 2006 19:31:28 -0500
David Given wrote:
Roberto Ierusalimschy wrote:
But it seems that casting (double)-1 to an unsigned int will result in
daemons flying out of our noses.
From my understanding of the specification, that's correct. It will.
It just so happens that on all platforms and all compilers that I know of it
produces the same result as (int)(unsigned int)(double)-1, but that's
(You know, it would be rather informative some time to put together a C
compiler which actually *checked* for all these undefined behaviour cases. I
suspect we might learn something...)
So, to be safe, maybe I should do this?
#define lua_number2integer(i, d) ((d) < 0 ? (i) = (int)(d) : (i) =