07 October 2012

Single precision floating point variable

Single-precision floating-point format is a computer number format that occupies 4 bytes (32 bits) in computer memory, known as float in C.

IEEE 754 is a technical standard for floating-point computation.


Converting from decimal to single-precision binary:
26.25

.25 x 2 = 0.50 -> 0
.50 x 2 = 1.00 -> 1

26.25 = 1A.25 = 0001 1010 . 01 = 1.101001 x 2^4

0 (127+4) 101001 = 0 (131) 101001
0 10000011 101001 = 0100 0001 1101 0010 = 0x41D20000

Converting from single-precision binary to decimal:
471BCF90 = 0100 0111 0001 1011 1100 1111 1001 0000

0 10001110 00110111100111110010000 = 0 (142-127) XYZ

1 . 00110111100111110010000 x 2^15 = 1001 1011 1100 1111 . 1001

1x2^-1 + 1x2^-4 =  .5 + .0625 = .5625

9BCF . 1001 = 39887 . 5625 = 39887.5625

Reference:
http://en.wikipedia.org/wiki/Single_precision
http://sandbox.mc.edu/~bennet/cs110/flt/dtof.html
http://www.exploringbinary.com/pi-and-e-in-binary/

No comments:

Post a Comment