

Technical Support OnLine Manuals C166 User's Guide C166 Introduction Compiling Programs Language Extensions Preprocessor Advanced Programming Sections, Classes, and Groups Special Sections Locating Sections Customization Files Startup Code STARTUP.A66 START167.A66 START_V2.A66 START_V3.A66 Basic I/O Memory Allocation TRAPS.C Optimizer Optimizer Options General Optimizations 80C166Specific Optimizations Global Register Coloring DPP Registers Stacks System Stack User Stack Stack Sizes System Stack Size User Stack Size XBUS Memory and Peripherals Onchip XRAM XBUS Peripherals Interfacing C to Assembler Function Parameters Function Return Values Using the SRC Directive Register Usage Example Routines TINY Model SMALL Model COMPACT Model MEDIUM Model LARGE Model Data Storage Formats Bit Variables 1byte Scalars 2byte Scalars 4byte Scalars float Scalars float Errors double Scalars double Errors near Pointers far Pointers huge Pointers xhuge Pointers Absolute Memory Access Absolute Access Macros Linker Location Controls Debugging Error Messages Library Reference Appendix 
float ScalarsScalars of type float are stored using four bytes (32bits). The format used follows the IEEE754 standard and is stored little endian or LSB first. A floatingpoint number is expressed as the product of two parts: the mantissa and a power of two. For example: ±mantissa × 2^{exponent} The mantissa represents the actual binary digits of the floatingpoint number. The power of two is represented by the exponent. The stored form of the exponent is an 8bit value from 0 to 255. 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 24bit 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 floatingpoint number is positive or negative. Floatingpoint numbers are stored on word boundaries in the following format:
Where
Zero is a special value denoted with an exponent field of 0 and a mantissa of 0. Using the above format, the floatingpoint number 12.5 is stored as a hexadecimal value of 0xC1480000. In memory, this value appears as follows:
It is fairly simple to convert floatingpoint numbers to and from their hexadecimal storage equivalents. The following example demonstrates how this is done for the value 12.5 shown above. The floatingpoint storage representation is not an intuitive format. To convert this to a floatingpoint number, the bits must be separated as specified in the floatingpoint number storage format table shown above. For example:
From this illustration, you can determine the following:
There is an understood binary point at the left of the mantissa that is always preceded by a 1. This digit is omitted from the stored form of the floatingpoint number. Adding 1 and the binary point to the beginning of the mantissa gives the following value: 1.10010000000000000000000 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: 1100.10000000000000000000 The result is a binary floatingpoint number. Binary digits to the left of the decimal point represent the power of two corresponding to their position. For example, 1100 represents (1 × 2^{3}) + (1 × 2^{2}) + (0 × 2^{1}) + (0 × 2^{0}), which is 12. Binary digits to the right of the decimal point also represent the power of two corresponding to their position. However, 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’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.