IT lexicon › Programming › Soft-float

Soft-float

Programming På svenska → Updated: 2026-11-04

Floating-point arithmetic carried out by library routines instead of a floating-point unit, because the CPU has none.

A Cortex-M0 or an AVR has no FPU. Write float y = x * 1.5f; anyway and the compiler turns the multiply into a call such as __aeabi_fmul in libgcc, which unpacks exponent and mantissa, does the work with integers and rounds according to IEEE 754. It works, but each operation costs tens to hundreds of cycles and the routines take a few kilobytes of flash.

GCC controls this with -mfloat-abi: soft does everything in software, softfp uses the FPU but passes arguments in integer registers, and hard passes floats in FPU registers. Mix libraries built with different settings and the linker refuses — a classic lost afternoon. The trap is that a Cortex-M4F only does single precision; one stray double or a missing f suffix quietly drops you back into software. Which is why plenty of firmware goes fixed-point from day one.

← Back to the lexicon