For a test case I'm generating random bytes and decoding them as Decimal32. It seems like this library doesn't handle non-canonical values, and the comment on the coefficient() method is invalid.
With the test input [0x78, f1, 5b, a3] decoded using Decimal32::from_be_bytes, I get a value which shows as 'Infinity' when printed, but has a coefficient of 56723 (not zero) and an exponent of 2013265920 (not valid).
It would also be nice to have dedicated methods to check if a decoded decimal number is NaN or Infinity, maybe is_finite, is_infinite, is_nan, is_normal, is_subnormal as with the native float types.
For a test case I'm generating random bytes and decoding them as
Decimal32. It seems like this library doesn't handle non-canonical values, and the comment on thecoefficient()method is invalid.With the test input
[0x78, f1, 5b, a3]decoded usingDecimal32::from_be_bytes, I get a value which shows as 'Infinity' when printed, but has a coefficient of 56723 (not zero) and an exponent of 2013265920 (not valid).It would also be nice to have dedicated methods to check if a decoded decimal number is NaN or Infinity, maybe
is_finite,is_infinite,is_nan,is_normal,is_subnormalas with the native float types.