summaryrefslogtreecommitdiff
path: root/libc/src/__support/FPUtil/NormalFloat.h
diff options
context:
space:
mode:
Diffstat (limited to 'libc/src/__support/FPUtil/NormalFloat.h')
-rw-r--r--libc/src/__support/FPUtil/NormalFloat.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/libc/src/__support/FPUtil/NormalFloat.h b/libc/src/__support/FPUtil/NormalFloat.h
index 8bc1fecd653b..413d20430090 100644
--- a/libc/src/__support/FPUtil/NormalFloat.h
+++ b/libc/src/__support/FPUtil/NormalFloat.h
@@ -52,7 +52,7 @@ template <typename T> struct NormalFloat {
return;
unsigned normalization_shift = evaluate_normalization_shift(mantissa);
- mantissa = mantissa << normalization_shift;
+ mantissa <<= normalization_shift;
exponent -= normalization_shift;
}
@@ -110,9 +110,11 @@ template <typename T> struct NormalFloat {
if (shift <= FPBits<T>::FRACTION_LEN + 1) {
// Generate a subnormal number. Might lead to loss of precision.
// We round to nearest and round halfway cases to even.
- const StorageType shift_out_mask = (StorageType(1) << shift) - 1;
+ const StorageType shift_out_mask =
+ static_cast<StorageType>(StorageType(1) << shift) - 1;
const StorageType shift_out_value = mantissa & shift_out_mask;
- const StorageType halfway_value = StorageType(1) << (shift - 1);
+ const StorageType halfway_value =
+ static_cast<StorageType>(StorageType(1) << (shift - 1));
result.set_biased_exponent(0);
result.set_mantissa(mantissa >> shift);
StorageType new_mantissa = result.get_mantissa();
@@ -135,7 +137,8 @@ template <typename T> struct NormalFloat {
}
}
- result.set_biased_exponent(exponent + FPBits<T>::EXP_BIAS);
+ result.set_biased_exponent(
+ static_cast<StorageType>(exponent + FPBits<T>::EXP_BIAS));
result.set_mantissa(mantissa);
return result.get_val();
}
@@ -155,7 +158,7 @@ private:
// Normalize subnormal numbers.
if (bits.is_subnormal()) {
unsigned shift = evaluate_normalization_shift(bits.get_mantissa());
- mantissa = StorageType(bits.get_mantissa()) << shift;
+ mantissa = static_cast<StorageType>(bits.get_mantissa() << shift);
exponent = 1 - FPBits<T>::EXP_BIAS - shift;
} else {
exponent = bits.get_biased_exponent() - FPBits<T>::EXP_BIAS;