fmul-to-int

Crates.iofmul-to-int
lib.rsfmul-to-int
version1.0.0
sourcesrc
created_at2024-02-05 13:20:27.148436
updated_at2024-02-05 13:20:27.148436
descriptionFloat multiplication to integer part.
homepage
repositoryhttps://github.com/timothee-haudebourg/fmul-to-int
max_upload_size
id1127582
size20,399
Timothée Haudebourg (timothee-haudebourg)

documentation

https://docs.rs/fmul-to-int

README

Float multiplication to integer part

Crate informations License Documentation

This library provides the mul_to_int function for f32 and f64 that allows one to multiply two float numbers and keep the integer part of the result without loss of precision. The fractional part is truncated.

Usage

Just import the FloatMulToInt trait to have access to the mul_to_int method.

use fmul_to_int::FloatMulToInt;

assert_eq!(11.0f64.mul_to_int(1_000_000_000.0).unwrap(), 11_000_000_000i128);
Commit count: 0

cargo fmt