Single precision

From Wikipedia, the free encyclopedia

In computing, single precision is a computer numbering format that occupies one storage location in computer memory at a given address. A single-precision number, sometimes simply a single, may be defined to be an integer, fixed point, or floating point.

Modern computers with 32-bit words (single precision) provide 64-bit double precision. Single precision floating point is an IEEE 754 standard for encoding floating point numbers that uses 4 bytes.

Contents

[edit] Single precision memory format

 Sign bit: 1
 Exponent width: 8  
 Significand precision: 23

The format is written with an implicit most-significant bit with value 1 unless the written exponent is all zeros. Thus only 23 bits of the fraction mantissa appear in the memory format but the total precision is 24 bits.

Image:Float_example.PNG

[edit] Exponent encodings

 Emin (0x01) = -126
 Emax (0xfe) = 127
 Exponent bias (0x7f) = 127

The true exponent = written exponent - exponent bias

 0x00 and 0xff  are reserved exponents 
 0x00 is used to represent zero and denormals
 0xff is used to represent infinity and NaNs

All bit patterns are valid encodings.

[edit] Single precision examples in hexadecimal

 3f80 0000   = 1
 c000 0000   = -2
 7f7f ffff   ~ 3.4028234 x 1038  (Max Single)
 3eaa aaab   ~ 1/3

By default, 1/3 rounds up instead of down like double precision, because of the even number of bits in the significand. So the bits beyond the rounding point are 1010... which is more than 1/2 of a unit in the last place.

 0000 0000   = 0
 8000 0000   = -0
 7f80 0000   = Infinity
 ff80 0000   = -Infinity

[edit] See also

In other languages