diff --git a/fixed_wide/src/fixed.rs b/fixed_wide/src/fixed.rs index 985d530..ac972bb 100644 --- a/fixed_wide/src/fixed.rs +++ b/fixed_wide/src/fixed.rs @@ -173,7 +173,7 @@ macro_rules! impl_into_float { msb_offset<<($mantissa_bits-1) }; let digits=unsigned.digits(); - let digit_index=most_significant_bit>>DIGIT_SHIFT; + let digit_index=most_significant_bit.saturating_sub(1)>>DIGIT_SHIFT; let digit=digits[digit_index as usize]; //How many bits does the mantissa take from this digit let take_bits=most_significant_bit-(digit_index<