Crates.io | srmfpa |
lib.rs | srmfpa |
version | 0.1.1 |
source | src |
created_at | 2024-06-29 14:32:12.97601 |
updated_at | 2024-06-30 08:58:22.551327 |
description | Floating-point's four arithmetic operations (including fused multiply-add) and square root with strict rounding mode |
homepage | |
repository | https://github.com/paqira/srmfpa |
max_upload_size | |
id | 1287401 |
size | 129,660 |
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);
softfloat
: use softfloat for f32
and f64
(enable f32_softfloat
and f64_softfloat
).f32_softfloat
: support softfloat f32
by Berkeley SoftFloat 3.f64_softfloat
: support softfloat f64
by Berkeley SoftFloat 3.f16_softfloat
: support softfloat f16
by Berkeley SoftFloat 3.f128_softfloat
: support softfloat f128
by Berkeley SoftFloat 3.MIT or Apache-2.0