srmfpa

Crates.iosrmfpa
lib.rssrmfpa
version0.1.1
sourcesrc
created_at2024-06-29 14:32:12.97601
updated_at2024-06-30 08:58:22.551327
descriptionFloating-point's four arithmetic operations (including fused multiply-add) and square root with strict rounding mode
homepage
repositoryhttps://github.com/paqira/srmfpa
max_upload_size
id1287401
size129,660
(paqira)

documentation

README

srmfpa

Crates.io Version Crates.io MSRV GitHub Actions Workflow Status docs.rs Crates.io License

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

Licence

MIT or Apache-2.0

Commit count: 69

cargo fmt