Keil Logo

Floating-point Numbers

Scalars of type float are stored using four bytes (32-bits). float type numbers have a precision of 24 bits, which represents about 7 decimal digits. The format used follows the IEEE-754 standard.

A floating-point number is expressed as the product of two parts: the mantissa and the exponent. For example:

±mantissa × 2exponent

The mantissa represents the actual binary digits of the floating-point number.

The exponent is represented by the power of two. The exponent is an 8-bit value from 0 to 255 and is stored relative to 127. The actual value of the exponent is calculated by subtracting 127 from the stored value (0 to 255), giving a range of –127 to +128.

The mantissa is a 24-bit value (representing about seven decimal digits) whose most significant bit (MSB) is always 1 and is, therefore, not stored. There is also a sign bit that indicates whether the floating-point number is positive or negative.

Floating-point numbers are stored on byte boundaries in the following format:

  Address+0 Address+1 Address+2 Address+3


S represents the sign bit where 1 is negative and 0 is positive.
E is the exponent with an offset of 127.
M is the 24-bit mantissa (stored in 23 bits). The highest bit is always 1 and, therefore, is not stored.

Zero is a special value denoted with an exponent field of 0 and a mantissa of 0.

Using the above format, the floating-point number -12.5 is stored as a hexadecimal value of 0xC1480000. In memory, this value appears as follows:

  Address+0 Address+1 Address+2 Address+3
Contents 0xC1 0x48 0x00 0x00

It is fairly simple to convert floating-point numbers to and from their hexadecimal storage equivalents. The following example demonstrates how this is done for the value -12.5 shown above.

The floating-point storage representation is not an intuitive format. To convert this to a floating-point number, the bits must be separated as specified in the floating-point number storage format table shown above. For example:

  Address+0 Address+1 Address+2 Address+3
Binary 11000001 01001000 00000000 00000000
Hex C1 48 00 00

From this illustration, you can determine the following:

  • The sign bit is 1, indicating a negative number.
  • The exponent value is 10000010 binary or 130 decimal. Subtracting 127 from 130 leaves 3, which is the actual exponent.
  • The mantissa appears as the following binary number:

There is an understood binary/decimal point at the left of the mantissa that is always preceded by a 1. This digit is omitted from the stored form of the floating-point number. Adding 1 and the binary/decimal point to the beginning of the mantissa gives the following value:


To adjust the mantissa for the exponent, move the decimal point to the left for negative exponent values or right for positive exponent values. Since the exponent is three, the mantissa is adjusted as follows:


The result is a binary floating-point number. Binary digits to the left of the decimal point represent the power of two corresponding to their position. For example, 1100 represents (1 × 23) + (1 × 22) + (0 × 21) + (0 × 20), which is 12.

Binary digits to the right of the decimal point also represent the power of two corresponding to their position. However, because these digits are tto the right of the decimal point, the powers are negative. For example, .100... represents (1 × 2-1) + (0 × 2-2) + (0 × 2-3) + ... which equals .5.

The sum of these values is 12.5. Because the sign bit was set, this number should be negative.

So, the hexadecimal value 0xC1480000 is -12.5.

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.