Computer
Systems

Spring 2013
course
navigation

Feb 14

Finish discussion of floating point :
The attached little.c looks at a floating point version of 0x1234, in part to see if the bytes were reversed in little-endian form.
And the answer is ... *yes* the floating point is little-endian. The bytes need to be reversed before parsing into (sign, exponent, fraction).
/* from little.c */ int i = 0x1234; float x = 0x1234; float y = 0x2468; show_bytes(&i, 4); show_bytes(&x, 4); show_bytes(&y, 4); $ ./little at 0xbff9b67c : 0x34 0x12 0x0 0x0 # i bytes are reversed at 0xbff9b678 : 0x0 0xa0 0x91 0x45 # x ditto at 0xbff9b674 : 0x0 0xa0 0x11 0x46 # y ditto Reversed to undo little-endian : i integer bytes : 0x 00 00 12 34 x float bytes : 0x 45 91 a0 00
and those float bytes as bits are
0100 0101 1001 0001 1010 0000 0000 0000
which are organized as (1 sign bit, 8 exp bits, 23 frac bits)
0 10001011 00100011010000000000000
With the (implied) leading 1, the value mantissa=1+frac is
100100011010000000000000
which with the exponent handled correctly is actually
1 0010 0011 0100 1 2 3 4 ... which is the 0x1234 .

machine code

We took a brief tour of some ideas from chapter 3.
my examples :
Also see
http://cs.marlboro.edu/ courses/ spring2013/systems/ notes/ Feb_14
last modified Thursday February 14 2013 1:00 pm EST

attachments [paper clip]

     name last modified size
[TXT]gcc_notes.txt Feb 14 2013 1:53 am 5.29kB [COD]little.c Feb 14 2013 12:55 pm 414B