niklaus@gamebox.net (Niklaus) wrote:
[color=blue]
> "Arthur J. O'Dwyer" <ajo@nospam.andrew.cmu.edu> wrote in message news:<Pine.LNX.4.58-035.0405031827470.14604@unix47.andrew.cmu.edu>...[color=green]
> > On Mon, 3 May 2004, Niklaus wrote:[color=darkred]
> > >
> > > int i = 3;
> > > double j;
> > > j = (double) i;
> > >
> > > What happens in the above statement ? Can someone
> > > explain me at bit level or a considerable explantion ?[/color]
> >
> > On the average Wintel machine, this will retrieve the bits stored
> > in i (say, 0x0300), and pass them through a special function designed
> > specifically to convert "int bits" to "float bits." On the x86 line
> > of processors, the FPU has a special machine instruction that will do
> > this conversion. The result will be a bunch of bits that represent
> > a float value (say, 0x42DE; I don't know the real internals here).
> > These "float bits" get stored into the object denoted by j.
> >[/color]
> Thanks for the explanation. I would like to know the real internals.[/color]
The problem is that, from an ISO C point of view, there are no _the_
real internals. What happens at the bit level is different for each
architecture you do this on. All the C Standard defines is what the
result should be (j is now equal to 3.0), not how that result should be
achieved (such-and-such a bit is shuffled into so-and-so a position).
This is because the natural way to get the required result depends
highly on how both floats and ints are represented on the computer in
question.
So yes, you do need to ask this in another group; however, only you know
what systems you want to know this about, so only you can tell whether
you want comp.sys.amiga.something or microsoft.public.vc.something-else.
Richard
[ Oh, btw, snipping is not forbidden in comp.lang.c ;-) ]