diff --git a/include/fp16/fp16.h b/include/fp16/fp16.h index 6fde4ca..be0bb3c 100644 --- a/include/fp16/fp16.h +++ b/include/fp16/fp16.h @@ -419,7 +419,6 @@ static inline uint16_t fp16_alt_from_fp32_value(float f) { const float bias = fp32_from_bits((shl1_bias >> 1) + ((exp_difference + 2) << 23)); const float base = fp32_from_bits((shl1_base >> 1) + (2 << 23)) + bias; - const uint32_t bias_difference = 0x7F - 0xF; const uint32_t exp_f = fp32_to_bits(base) >> 13; return (sign >> 16) | ((exp_f & UINT32_C(0x00007C00)) + (fp32_to_bits(base) & UINT32_C(0x00000FFF))); } diff --git a/test/ieee-to-fp32-bits.cc b/test/ieee-to-fp32-bits.cc index a92e1dd..284e1b1 100644 --- a/test/ieee-to-fp32-bits.cc +++ b/test/ieee-to-fp32-bits.cc @@ -248,7 +248,7 @@ TEST(FP16_IEEE_TO_FP32_BITS, positive_nan) { "F32(F16) = 0x" << std::setw(8) << nan_f32; /* Check mantissa */ - EXPECT_NE(nan_f32 & UINT32_C(0x007FFFFF), 0) << + EXPECT_NE(nan_f32 & UINT32_C(0x007FFFFF), UINT32_C(0)) << std::hex << std::uppercase << std::setfill('0') << "F16 = 0x" << std::setw(4) << nan_f16 << ", " << "F32(F16) = 0x" << std::setw(8) << nan_f32; @@ -261,7 +261,7 @@ TEST(FP16_IEEE_TO_FP32_BITS, negative_nan) { const uint32_t nan_f32 = fp16_ieee_to_fp32_bits(nan_f16); /* Check sign */ - EXPECT_NE(nan_f32 & UINT32_C(0x80000000), 0) << + EXPECT_NE(nan_f32 & UINT32_C(0x80000000), UINT32_C(0)) << std::hex << std::uppercase << std::setfill('0') << "F16 = 0x" << std::setw(4) << nan_f16 << ", " << "F32(F16) = 0x" << std::setw(8) << nan_f32; @@ -273,7 +273,7 @@ TEST(FP16_IEEE_TO_FP32_BITS, negative_nan) { "F32(F16) = 0x" << std::setw(8) << nan_f32; /* Check mantissa */ - EXPECT_NE(nan_f32 & UINT32_C(0x007FFFFF), 0) << + EXPECT_NE(nan_f32 & UINT32_C(0x007FFFFF), UINT32_C(0)) << std::hex << std::uppercase << std::setfill('0') << "F16 = 0x" << std::setw(4) << nan_f16 << ", " << "F32(F16) = 0x" << std::setw(8) << nan_f32;