mamrhein / fpdec.rs

Fast implementation of Decimal fixed-point arithmetics
BSD 3-Clause "New" or "Revised" License
17 stars 4 forks source link

Cast to primitive types #7

Closed baist0 closed 1 year ago

baist0 commented 1 year ago

Does fpdec lib has any conversion to another type(isize, u8, i16)?

mamrhein commented 1 year ago

No. But converting to an int is easy:

use fpdec::Dec;
let d: Decimal = Dec!(17.34);
let i = d.trunc().coefficient() as i16;
println!("{i}");