Immediate Constants - 2024.2 English

MicroBlaze Processor Reference Guide (UG984)

Document ID
UG984
Release Date
2024-11-27
Version
2024.2 English

Floating-point constants in C are double-precision by default. When using a single-precision FPU, careless coding could result in double-precision software emulation routines being used instead of the native single-precision instructions. To avoid this, explicitly specify (by cast or suffix) that immediate constants in your arithmetic expressions are single-precision values.

For example:

float x = 0.0;
...
x += (float)1.0;                       /* float addition */
x += 1.0F;                             /* alternative to above */
x += 1.0;                              /* warning - uses double addition! */
Note: The GNU C compiler can be instructed to treat all floating-point constants as single-precision (contrary to the ANSI C standard) by supplying the compiler flag -fsingle-precision-constants.