John Hauser

Berkeley SoftFloat

Berkeley SoftFloat is a free, high-quality software implementation of binary floating-point that conforms to the IEEE Standard for Floating-Point Arithmetic. SoftFloat is completely faithful to the IEEE Standard, while at the same time being relatively fast. All functions dictated by the original 1985 version of the standard are supported except for conversions to and from decimal. The latest release of SoftFloat implements five floating-point formats: 16-bit half-precision, 32-bit single-precision, 64-bit double-precision, 80-bit double-extended-precision, and 128-bit quadruple-precision. All required rounding modes, exception flags, and special values are supported. Fused multiply-add is also implemented for all formats except 80-bit double-extended-precision.

SoftFloat is distributed in the form of ISO/ANSI C source code and should be compilable with almost any ISO-compliant C compiler. Using the GNU C Compiler (gcc), the package has been compiled and tested for several platforms. Target-specific code is provided for various Intel x86 processors. Other machines can be targeted using these as examples.

Since Release 3, SoftFloat has depended on the existence of a 64-bit integer type in C. If the C compiler used to compile SoftFloat does not support 64-bit integers, it is still possible to use the older Release 2c to implement the two most common formats, 32-bit single-precision and 64-bit double-precision, but not the other formats.

Release 3c

Release 3 was a complete rewrite of SoftFloat, funded by the University of California, Berkeley. That release added functions for converting to and from unsigned integers, functions for fused multiply-add, and better algorithms for division, remainder, and square root. Unlike earlier versions, Release 3 and later have a U.C. Berkeley open-source license (specified in the documentation).

The latest version of SoftFloat is Release 3c (2017 February). This version adds optional support for the rarely used rounding mode round to odd, also known as jamming. The previous Release 3b mainly added 16-bit half-precision to the supported formats. No bugs have yet been reported in the floating-point functions since the original Release 3 from early 2015, so updating to newer releases should not be needed to fix any bugs. Information about this release is in the following files from the SoftFloat package:
-- SoftFloat.html - Berkeley SoftFloat Release 3c: Library Interface. This document includes a section on the many differences between Release 3 and the earlier Release 2.
-- SoftFloat-source.html - Berkeley SoftFloat Release 3c: Source Documentation.
-- SoftFloat-history.html - History of Berkeley SoftFloat, to Release 3c.

The following archive contains all source code and documentation for Release 3c:
-> zip archive, [657 kB].

The older Releases 3a and 3b are still available here:
-> zip archive, [655 kB].
-> zip archive, [563 kB].

Release 2c

For those who may need it, SoftFloat versions preceding Release 3 have been updated to Release 2c (2015 January). The only changes in this release compared to earlier releases 2a and 2b are these:

If you have been successfully using Release 2a or 2b on a 32-bit processor (or compiled as though for a 32-bit processor), you probably do not need to download this release.
-> zip archive, [108 kB].

Testing SoftFloat

Once compiled, SoftFloat can be tested using the testsoftfloat program of Berkeley TestFloat:
[] Berkeley TestFloat is a small collection of programs for testing that an implementation of binary floating-point conforms to the IEEE Standard for Floating-Point Arithmetic.

SoftFloat speed

The following table shows the speeds of some of SoftFloat's functions on machines of different strengths. For this table, SoftFloat was compiled using the GNU C Compiler with only ordinary optimization enabled (gcc -O2). Speeds are reported in Mop/s (millions of floating-point operations per second). Function times are affected by operand values and cache effects, among other factors, so your results may vary.

speed (Mop/s)
32-bit single 64-bit double 80-bit
add mul div add mul div add mul div add mul div
1-GHz ARM Cortex-A8 (32-bit),
32-kB I/D caches, Linux, GCC 4.6.3
8.30 10.9 7.23 4.96 5.23 4.19 5.21 5.28 2.20 3.50 2.35 1.14
2.2-GHz Intel Xeon E5-2430 (64-bit),
Linux, GCC 4.8.5
47.3 73.3 42.0 43.9 57.5 30.5 35.5 45.4 20.6 31.6 22.4 15.7

Related sites

[] The fp (floating-point) directory of the Netlib Repository. Includes C subroutines for converting to and from decimal textual formats (e.g., strtod).
[] The Freely Distributable LIBM (fdlibm), an implementation of the C math library (sin, exp, log, etc.), also at the Netlib Repository.
[] Sun Microsystems' Numerical Computation Guide, which covers the IEEE Standard in detail. (Sun Microsystems was acquired by Oracle in 2010.)
[] My article “Handling floating-point exceptions in numeric programs,” explaining how the exception handling features of the IEEE Standard can be applied to real programs.

Credit and contacts

Berkeley SoftFloat was written by me, John R. Hauser. Funding for the development of SoftFloat Release 3 and later was provided indirectly by portions of grants to U.C. Berkeley from Microsoft, Intel, DARPA, Nokia, NVIDIA, Oracle, Samsung, and Google, and by a portion of a U.C. Discovery Grant. The SoftFloat documentation has more details.

Bugs in SoftFloat and other comments can be reported to me at

John Hauser, 2017 February 10