1 unstable release
0.1.0 | Oct 15, 2023 |
---|
#29 in #ident
9KB
125 lines
i2f
Macros that converts number literals into int or float literals.
In addition to literals, we also accept negative literals -literal
.
Examples
i2f!(90) //90.0
i2f!(-462) //-462.0
i2f!(3.14) //3.14
f2i!(3), //3
f2i!(3.0), //3
trunc!(3.14), //3
f2i!(-12.0), //-12
lib.rs
:
Macros that converts number literals into int or float literals.
In addition to literals, we also accept negative literals -literal
.
Examples
use i2f::*;
assert_eq!(i2f!(90), 90.0);
assert_eq!(i2f!(-462), -462.0);
assert_eq!(i2f!(3.14), 3.14);
assert_eq!(f2i!(3), 3);
assert_eq!(f2i!(3.0), 3);
assert_eq!(f2i!(-12.0), -12);
assert_eq!(trunc!(3.14), 3);
assert_eq!(trunc!(-3.14), -3);
Dependencies
~310KB