#f32 #f64 #round #float

no-std round_float

Round f64 and f32 to specified number of decimals

15 releases (5 stable)

1.2.2 Aug 26, 2024
1.1.2 Aug 26, 2024
1.0.1 Apr 22, 2024
0.0.12 Apr 12, 2024

#949 in Algorithms

Download history 305/week @ 2024-08-22 60/week @ 2024-08-29 30/week @ 2024-09-12 12/week @ 2024-09-19 20/week @ 2024-09-26 13/week @ 2024-10-03

773 downloads per month

MIT/Apache

7KB

This crate extends your float numbers (f64 and f32) with the trait method round_to_fraction(), which lets you round the float number to a specified number of fraction digits.

Example

use round_float::RoundToFraction;

let full_float = 12.34567;
let rounded_float = full_float.round_to_fraction(2);

assert_eq!(rounded_float, 12.35);

Dependencies

~200–285KB