Fix handling of inf and nan in TFloat16

This commit is contained in:
2025-03-10 11:03:17 +01:00
parent bd45900821
commit d0dbef20c7
+8 -1
View File
@@ -27,6 +27,12 @@ public:
b16 |= sign;
b16 |= mantisa;
}
else if(exp == 255)//inf or nan
{
b16 = 0x7c00;
b16 |= sign;
b16 |= mantisa;
}
else if(exp > 142)
{
b16 = 0x7c00;// inf
@@ -51,7 +57,8 @@ public:
if(b16)
{
i |= sign << 16;
i |= (exp + 112) << 23;
if(exp==31)i |= 0x7f800000;
else i |= (exp + 112) << 23;
i |= (b16 & 0x3ff) << 13;
}
return *reinterpret_cast<float*>(&i);