# Floating-point without FPU

Since a Floating Point Unit (FPU) is not present in Arduino Uno, I wanted to know how float operations are performed. If it is simulated as integer operations, I want to know how exactly the simulation is done.

• Floating point operations are implemented (rather than “simulated”) in software. You can disassemble any program using floats and see how it's done. Commented Sep 28, 2017 at 7:19
• Implementing floating point in software would mean breaking the number into its mantissa and exponent components (represented as integers) and performing arithmetic on them. Is this correct? Commented Sep 28, 2017 at 8:21
• Of course. The splitting is done by the function `__fp_split3`. Commented Sep 28, 2017 at 8:34

As I said in my comment, all float operations are implemented in software. As a simple test, I compiled the following program:

``````volatile float x, y, z;

int main(void)
{
z = x + y;
return 0;
}
``````

The compiler translated the sum operation into a call to `__addsf3`. This function extends its arguments to `flt40_t` format (non-standard 40 bits float), calls `__addsf3x` to do the 40-bit addition, then calls `__fp_round` to convert the result into the standard `float` format. `__addsf3x` also makes a few library calls of its own. In the end, the addition pulled the following functions into the compiled program: `__subsf3`, `__addsf3`, `__addsf3x`, `__fp_inf`, `__fp_nan`, `__fp_pscA`, `__fp_pscB`, `__fp_round`, `__fp_split3`, `__fp_splitA`, `__fp_zero` and `__fp_szero`.

All these functions are provided by the avr-libc. You can find them in the libm/fplib directory. See for example the files:

software emulation. The float is decomposed into sign, exponent and mantissa and then integer operations are used to do the actual math.

Addition and subtraction means shifting the mantissas to a common magnitude, adding/subtracting them and then checking the highest set bit for the new exponent.

Multiplication means adding the exponents and multiplying the mantissas. Division is subtracting.