fixed rounding to float16 (found during AVX512_FP16 development)

used Softfloat3 code as reference
This commit is contained in:
Stanislav Shwartsman 2024-01-26 22:53:39 +02:00
parent 093d4428ec
commit e14b126198

View File

@ -281,11 +281,13 @@ float16 roundAndPackFloat16(int zSign, Bit16s zExp, Bit16u zSig, float_status_t
} }
} }
} }
if (roundBits) float_raise(status, float_flag_inexact); if (roundBits) float_raise(status, float_flag_inexact);
Bit16u zSigRound = ((zSig + roundIncrement) & ~roundMask) >> 4; zSig = (zSig + roundIncrement)>>4;
zSigRound &= ~(((roundBits ^ 0x10) == 0) & roundNearestEven); zSig &= ~(Bit16u) ((!(roundBits ^ 8)) & roundNearestEven);
if (zSigRound == 0) zExp = 0; if (! zSig) zExp = 0;
return packFloat16(zSign, zExp, zSigRound);
return packFloat16(zSign, zExp, zSig);
} }
#endif #endif