On Tue, 26 Sep 2006 10:08:25 +0100, Chris Dollin <>
wrote in comp.lang.c:
> Al wrote:
>
> > can anyone tell me what the following means?
>
> You could try reading your C book, rather than asking
> for help.
>
> > x is a float, and j an
> > integer. What value is in j afterwards?
> >
> > j=0; j=(int)(x)&512;
>
> We don't know what float value `x` has, so we don't know what
> int value `(int)(x)` has (this could be written as `(int) x`),
> so we don't know what value `(int) x & 512` has, except that
> it's either 0 or 512, because of the way bitwise-& works.
No, it's undefined, and anything can happen. Accessing the value of
an uninitialized float produces the undefined behavior. Attempting to
cast to int and performing a bit-wise and has nothing to do with it,
the wheels have already fallen off before you get that far.
> The answer's either 0 or 128.
There is no answer here, either, since the behavior is still
undefined.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://c-faq.com/
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html