Unverified Commit ce75b918 authored by PanZezhong1725's avatar PanZezhong1725 Committed by GitHub
Browse files

Merge pull request #227 from John-jsh/issue/226

issue/226: 修改_f32_to_f16()方法内的判断语句条件
parents 1be004cb 7475f149
...@@ -43,7 +43,7 @@ fp16_t _f32_to_f16(float val) { ...@@ -43,7 +43,7 @@ fp16_t _f32_to_f16(float val) {
int32_t exponent = ((f32 >> 23) & 0xFF) - 127; // Extract and de-bias the exponent int32_t exponent = ((f32 >> 23) & 0xFF) - 127; // Extract and de-bias the exponent
uint32_t mantissa = f32 & 0x7FFFFF; // Extract the mantissa (fraction part) uint32_t mantissa = f32 & 0x7FFFFF; // Extract the mantissa (fraction part)
if (exponent >= 31) { // Special cases for Inf and NaN if (exponent >= 16) { // Special cases for Inf and NaN
// NaN // NaN
if (exponent == 128 && mantissa != 0) { if (exponent == 128 && mantissa != 0) {
return fp16_t{static_cast<uint16_t>(sign | 0x7E00)}; return fp16_t{static_cast<uint16_t>(sign | 0x7E00)};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment