LibBF Library
News
- 2025-06-03: New version with the BFCalc calculator application (web version
- IEEE 754
semantics (including subnormal numbers, infinities and NaN).
- All operations are exactly rounded using the 5 IEEE 754 rounding
modes (round to nearest with ties to even or away from zero, round
to zero, -/+ infinity). The additional non-deterministic faithful
rounding mode is supported when a lower or deterministic running
time is necessary.
- Stateless API (each function takes as input the rounding mode,
mantissa and exponent precisions in bits and return the IEEE status
flags).
- The basic arithmetic operations (addition, subtraction,
multiplication, division, square root) have a near linear running
time.
- Multiplication using a SIMD optimized Number Theoretic Transform.
- Exactly rounded floating point input and output in any base between
2 and 36 with near linear runnning time. Floating point output can
select the smallest amount of digits to get the required precision.
- Transcendental functions are supported (exp, log, pow, sin, cos, tan,
asin, acos, atan, atan2).
- Operations on arbitrarily large integers are supported by using a
special "infinite" precision. Integer division with remainder and
logical operations (assuming two complement binary representation)
are implemented.
- Arbitrary precision floating point numbers in base 10 corresponding
to the IEEE 754 2008 semantics with the limitation that the mantissa
is always normalized. The basic arithmetic operations, output and
input are supported with a quadratic running time.
- Easy to embed: a few C files need to be copied, the memory
allocator can be redefined, the memory allocation failures are
tested.
- MIT license.
Download
Source code: libbf-2025-06-03.tar.gz.
Related projects
LibBF has its roots in TinyPI. numcalc.com
Licensing
It is released under the
MIT license.
Fabrice Bellard -
https://bellard.org/