#decimal #place

yanked decimals

A Rust library for rounding to a number of decimal places

1 unstable release

Uses new Rust 2024

0.1.2 Mar 29, 2025
0.1.1 Mar 29, 2025
0.1.0 Mar 29, 2025

#61 in #place

Download history 305/week @ 2025-03-26 42/week @ 2025-04-02

347 downloads per month

MIT/Apache

4KB

Decimals

This module provides a single trait for rounding floating-point numbers to a specified number of decimal places. That's all!

This should really be part of the standard library, or at least in the num crate. But it's not!

Examples

use decimals::Decimals;

assert_eq!(1.23456789.round_to(2), 1.23);
assert_eq!(1.23456789.round_to(3), 1.235);

No runtime deps