2 releases
0.1.1 | Jun 30, 2024 |
---|---|
0.1.0 | Jun 29, 2024 |
#532 in Math
45 downloads per month
510KB
8K
SLoC
srmfpa
Floating-point's four arithmetic operations (including fused multiply-add) and square root with strict rounding mode.
use srmfpa::prelude::*;
// Support add, sub, mul, div, mul_add (fma) and sqrt
assert_eq!(0.1.round_ties_even_add(0.2), 0.30000000000000004);
assert_eq!(0.1.ciel_add(0.2), 0.30000000000000004);
assert_eq!(0.1.floor_add(0.2), 0.3);
assert_eq!(0.1.trunc_add(0.2), 0.3);
assert_eq!((-0.1).round_ties_even_add(-0.2), -0.30000000000000004);
assert_eq!((-0.1).ciel_add(-0.2), -0.3);
assert_eq!((-0.1).floor_add(-0.2), -0.30000000000000004);
assert_eq!((-0.1).trunc_add(-0.2), -0.3);
// Generic ops
assert_eq!(0.1.round_add(0.2, &RoundingMode::NearestTiesEven), 0.30000000000000004);
// Functions are available
use srmfpa::f64::{ciel_add, floor_add};
assert_eq!(ciel_add(0.1, 0.2), 0.30000000000000004);
assert_eq!(floor_add(0.1, 0.2), 0.3);
Features
softfloat
: use softfloat forf32
andf64
(enablef32_softfloat
andf64_softfloat
).f32_softfloat
: support softfloatf32
by Berkeley SoftFloat 3.f64_softfloat
: support softfloatf64
by Berkeley SoftFloat 3.f16_softfloat
: support softfloatf16
by Berkeley SoftFloat 3.f128_softfloat
: support softfloatf128
by Berkeley SoftFloat 3.
Licence
MIT or Apache-2.0
Dependencies
~185KB