diff --git a/src/fpga/common/fpga_common.cpp b/src/fpga/common/fpga_common.cpp index 0a1787aa3f211a247d95cd7124879ce14af980a9..bf90a3a11926b1f90ed8a659db908a061f79b0e9 100644 --- a/src/fpga/common/fpga_common.cpp +++ b/src/fpga/common/fpga_common.cpp @@ -76,7 +76,7 @@ int32_t convertmantissa(int32_t i) { } float fp16_2_fp32(int16_t fp16_num) { - int16_t se_fp16 = fp16_num >> 10; + int16_t se_fp16 = (fp16_num >> 10) & 0x3f; int16_t m_fp16 = fp16_num & 0x3ff; int32_t e_fp32 = 0; int16_t offset = 0; @@ -94,7 +94,7 @@ float fp16_2_fp32(int16_t fp16_num) { e_fp32 = 0x80000000; offset = 0; } else if (se_fp16 < 63) { - e_fp32 = 0x80000000 + (se_fp16 - 32) << 23; + e_fp32 = 0x80000000 + ((se_fp16 - 32) << 23); offset = 1024; } else { // se_fp16 == 63 e_fp32 = 0xC7800000;