Skip to content

A Rust floating point math library

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

eduardosm/rust-fpmath

Folders and files

NameName
Last commit message
Last commit date
Mar 15, 2025
Mar 15, 2025
Mar 17, 2025
Mar 17, 2025
Mar 14, 2025
Mar 14, 2025
Oct 14, 2024
Mar 14, 2025
Mar 14, 2025
Sep 17, 2024
Sep 17, 2024
Mar 11, 2025

Repository files navigation

fpmath

GitHub Actions Status crates.io Documentation MSRV License

fpmath is a pure-Rust floating point library that implements math functions for f32 and f64.

Features

  • Less than 1 ULP error in most functions.
  • f32 versions do not internally use f64 arithmetic.
  • All functions are also implemented for soft-float single-precision and double precision.
  • no_std
  • All functions are tested for accuracy (MPFR is used to calculate reference values).
  • The included generator crate can generate all magic constants used in the algorithms.

Included functions

  • Absolute value
  • Copy sign
  • Rounding (to nearest, towards zero, towards infinity, towards negative infinity)
  • Exponential in base e, 2 and 10
  • Logarithm in base e, 2 and 10
  • Trigonometric (sine, cosine, tangent) in radians, degrees and half-revolutions
  • Inverse trigonometric (arcsine, arccosine, arctangent) in radians, degrees and half-revolutions
  • Hyperbolic (sine, cosine, tangent)
  • Inverse hyperbolic (arcsine, arccosine, arctangent)
  • Square and cube root
  • Hypotenuse
  • Power (floating point and integer exponent)

Development

The code contains some generated constants. They can be identified with a comment that starts with // GENERATE:.

They can be regenerated with:

cargo run -p generator -- src

The generator needs Sollya and Julia to be installed.

License

Licensed under either of

at your option.

About

A Rust floating point math library

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published