loyd / fixnum

Fixed-point numbers
MIT License
7 stars 6 forks source link

Macro for const `FixedPoint` construction #7

Closed quasiyoke closed 1 year ago

quasiyoke commented 3 years ago

We'd like to have a macro allowing to const-antly construct FixedPoints out of literals:

fixed_point!(3) //=> 3.0
fixed_point!(0.12) //=> 0.12
fixed_point!(-123_456.789_987) //=> -123456.789987

Extra:

fixed_point!(3%) //=> 0.03
fixed_point!(3.45e-4) //=> 0.000345
loyd commented 1 year ago

The primary usage is covered by fixnum_const! for a long time.