I E E E S T A N D A R D F L O A T I N G P O I N T F O R M A T Carter Bays 11/96 Most computers manufactured after 1990 utilize IEEE floating point format, which is described below. Single ("float") objects are 32 bits: seee eeee efff ffff ffff ffff ffff ffff "Double" objects are 64 bits: seee eeee eeee ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff where: s = sign of fraction (as signed magnitude, not two's compliment) e = exponent (as a nine bit bit integer, two's complement form, where zero exponent is represented as 01111111, or "excess 127") f = fraction bits (since all numbers can be represented as 1.ffffff . . . , we strip off the leading "1", which the machine hardware adds back before any calculation) or, put another way, given the internal format: sEF (with E,F = e...e, f...f) then: (float) N = (-1)^s * 2^(E-127) * (1.F) (see J. P. Hayes, "Computer Organization and Architecture") Here are some easy steps to convert to floating point ("float", or 32 bit) 1) Find the binary value 1/3 = .01010101010 . . . 1 1/3 = 1.0101010101 . . . 17 = 10001.000000 . . . 40.75 = 101000.11000 . . . 2) convert to "1. . . ." times 2^e 1/3 = 1.01010101 . . . times 2^(-2) 1 1/3 = 1.01010101 . . . times 2^0 17 = 1.00010000 . . . times 2^4 40.75 = 1.01000110 . . . times 2^5 3) strip off the "1." This is "F" 1/3 F = 010101010 . . . 1 1/3 F = 010101010 . . . 17 F = 000100000 . . . 40.75 F = 010001100 . . . 4) Calculate the exponent, "E" as: 01111111 + eeeeeeee ( e...e below is expressed as decimal number ) 1/3 -> 01111111 + (-2) = 01111101 1 1/3 -> 01111111 + 0 = 01111111 17 -> 01111111 + 4 = 10000011 40.75 -> 01111111 + 5 = 10000100 5) Concatenate s, E, and F, getting sEF (for examples given, s=0 -> "+") 1/3 = 00111110101010101010 . . . 1 1/3 = 00111111101010101010 . . . 17 = 01000001100010000000 . . . 40.75 = 01000010001000110000 . . . 6) Convert to hexadecimal 1/3 = 3eaaaaab (last bit rounded up) 1 1/3 = 3faaaaab 17 = 41880000 40.75 = 42230000 7) If a number is negative, the first bit, s, is the sign of F and is set to 1 - 1/3 = beaaaaab -17 = c1880000 To convert from "float" to a decimal number, perform steps 1 - 7 in reverse order. (i.e. first determine the sign; then convert from hexadecimal to binary; etc.)