Keil Logo

Technical Support

On-Line Manuals

Libraries and Floating Point Support Guide

Preface The ARM C and C++ Libraries The ARM C Micro-library Floating-point Support About floating-point support The software floating-point library, fplib Calling fplib routines fplib arithmetic on numbers in a particular format fplib conversions between floats, long longs, doub fplib comparisons between floats and doubles fplib C99 functions Controlling the ARM floating-point environment Floating-point functions for compatibility with Mi C99-compatible functions for controlling the ARM f C99 rounding mode and floating-point exception mac Exception flag handling Functions for handling rounding modes Functions for saving and restoring the whole float Functions for temporarily disabling exceptions ARM floating-point compiler extensions to the C99 Writing a custom exception trap handler Example of a custom exception handler Exception trap handling by signals mathlib double and single-precision floating-point IEEE 754 arithmetic Basic data types for IEEE 754 arithmetic Single precision data type for IEEE 754 arithmetic Double precision data type for IEEE 754 arithmetic Sample single precision floating-point values for Sample double precision floating-point values for IEEE 754 arithmetic and rounding Exceptions arising from IEEE 754 floating-point ar Exception types recognized by the ARM floating-poi Using the Vector Floating-Point (VFP) support libr The C and C++ Library Functions reference Floating-point Support Functions Reference

Single precision data type for IEEE 754 arithmetic

3.5.2 Single precision data type for IEEE 754 arithmetic

A float value is 32 bits wide.

The structure is:
Figure 3-1 IEEE 754 single-precision floating-point format
IEEE 754 single-precision floating-point format

The S field gives the sign of the number. It is 0 for positive, or 1 for negative.
The Exp field gives the exponent of the number, as a power of two. It is biased by 0x7F (127), so that very small numbers have exponents near zero and very large numbers have exponents near 0xFF (255).
For example:
  • If Exp = 0x7D (125), the number is between 0.25 and 0.5 (not including 0.5).
  • If Exp = 0x7E (126), the number is between 0.5 and 1.0 (not including 1.0).
  • If Exp = 0x7F (127), the number is between 1.0 and 2.0 (not including 2.0).
  • If Exp = 0x80 (128), the number is between 2.0 and 4.0 (not including 4.0).
  • If Exp = 0x81 (129), the number is between 4.0 and 8.0 (not including 8.0).
The Frac field gives the fractional part of the number. It usually has an implicit 1 bit on the front that is not stored to save space.
For example, if Exp is 0x7F:
  • If Frac = 00000000000000000000000 (binary), the number is 1.0.
  • If Frac = 10000000000000000000000 (binary), the number is 1.5.
  • If Frac = 01000000000000000000000 (binary), the number is 1.25.
  • If Frac = 11000000000000000000000 (binary), the number is 1.75.
In general, the numeric value of a bit pattern in this format is given by the formula:
(–1)S * 2(Exp–0x7F) * (1 + Frac * 2–23)
Numbers stored in this form are called normalized numbers.
The maximum and minimum exponent values, 0 and 255, are special cases. Exponent 255 can represent infinity and store Not a Number (NaN) values. Infinity can occur as a result of dividing by zero, or as a result of computing a value that is too large to store in this format. NaN values are used for special purposes. Infinity is stored by setting Exp to 255 and Frac to all zeros. If Exp is 255 and Frac is nonzero, the bit pattern represents a NaN.
Exponent 0 can represent very small numbers in a special way. If Exp is zero, then the Frac field has no implicit 1 on the front. This means that the format can store 0.0, by setting both Exp and Frac to all 0 bits. It also means that numbers that are too small to store using Exp >= 1 are stored with less precision than the ordinary 23 bits. These are called denormals.
Non-ConfidentialPDF file icon PDF versionARM DUI0378H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  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.