Re: Form k = i + j and test for overflow.
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Sun, 01 Jul 2007 05:31:17 -0800
James Van Buskirk wrote:
(snip)
because C doesn't have an ASSOCIATED intrinsic, and C programmers
mostly aren't told to say:
if(ptr == SPECIAL_VALUE)
but instead:
if(ptr)
because the programmer is supposed to be able to tell whether or
not ptr points at something useful from whether the bit pattern of
ptr maps to true or false.
Note that for pointers, unlike other constants, the NULL pointer
is false and all others are true. While the usual NULL pointer
representation is all bits zero, the standard doesn't require
that. It does require that the constant zero cast to a pointer
be the NULL constant, though.
The problem for C programs lies in the fact that C boolean operators
spit out unique values for true and false results but any int in C
has a documented interpretation as true or false even though it may
not match one of the two bit patterns above.
With zero for false and non-zero for true. Now that you mention
it, I am not sure about negative zero....
-- glen
.
- Follow-Ups:
- Re: Form k = i + j and test for overflow.
- From: James Giles
- Re: Form k = i + j and test for overflow.
- Prev by Date: Re: Please help me understand my code
- Next by Date: Re: Please help me understand my code
- Previous by thread: Re: Form k = i + j and test for overflow.
- Next by thread: Re: Form k = i + j and test for overflow.
- Index(es):
Relevant Pages
|