Besides reliable, what requirements do you have?

If you want something generic use `trunc` 
(<https://nim-lang.org/docs/math.html#trunc%2Cfloat32)>.

If you want something fast, extract the mantissa bits from the float and shift 
by the exponent bits.

Example:

  * 
<https://github.com/numforge/laser/blob/d1e6ae61/laser/primitives/simd_math/exp_log_fallback.nim#L32-L38>
  * And float32 bit position: 
<https://github.com/numforge/laser/blob/d1e6ae61/laser/primitives/simd_math/exp_log_common.nim#L26-L38>



Good luck to support big-endian machine in that case though, and make sure to 
test with denormal, NaN, -Inf, +Inf

Reply via email to