Fix handling of inf and nan in TFloat16
This commit is contained in:
+8
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user