Some floating point libraries for Z80

I found this repository containing a wide selection of floating point libraries - one for every occasion.

Precision varies from 3.5 digits up to 15 and a bit. The lowest precision - a 16 bit float type - is of course fastest, and this graphics demo shows the benefit of that:

(Sometimes fixed point is appropriate and that should be faster still)

Within this library we find efforts from BBC Basic, from Microsoft, from DAI, and from more recent contributors.


Looks pretty useful if I ever need some Z-80 floating point action.

I’ve also bookmarked this low-precision library that does 8 bit mantissa, 7 bit exponent:


Richard Russell’s library for the Z88 is rather clever: re-entrant for the multitasking (kinda) OZ OS, uses variant types (in BASIC, at least) for integers to be calculated as such for as long as possible. Total size is about 3 KB. It’s quite heavy on stack use, but you have to put those intermediate values somewhere.

1 Like