#portable #strict #platform #results #ensure #fdlibm

rust-strictmath

Rust便携式严格数学实现

3个版本

0.1.2 2023年11月30日
0.1.1 2023年11月3日
0.1.0 2023年5月4日

612数学

每月下载量:29
用于 sketches-rust

Apache-2.0

260KB
5.5K SLoC

C 5K SLoC // 0.4% comments Rust 388 SLoC

rust-strictmath

该crate受java StrictMath 的启发。如果获得完全可预测的结果比运行速度更重要,则应使用此crate。此crate提供一系列浮点函数,以确保它们可以在不同的平台上产生相同的结果。这些算法来自知名的网络库 fdlibm

函数

  • acos
  • asin
  • atan
  • atan2
  • cbrt
  • cos
  • cosh
  • exp
  • expm1
  • hypot
  • log
  • log10
  • log1p
  • pow
  • sin
  • sinh
  • sqrt
  • tan
  • tanh

用法

在项目目录中运行以下Cargo命令

cargo add rust-strictmath

或者将以下行添加到您的Cargo.toml中

rust-strictmath = "0.1.2"

无运行时依赖

~0–2MB
~40K SLoC