Merge "Quiet SNaN inputs in Half.toFloat()"
am: a879fd8b02
Change-Id: I9ad4e399a81121ec0e59d8aa1af4cd05866c12cb
This commit is contained in:
@@ -162,6 +162,7 @@ public final class Half extends Number implements Comparable<Half> {
|
||||
private static final int FP32_EXPONENT_MASK = 0xff;
|
||||
private static final int FP32_SIGNIFICAND_MASK = 0x7fffff;
|
||||
private static final int FP32_EXPONENT_BIAS = 127;
|
||||
private static final int FP32_QNAN_MASK = 0x400000;
|
||||
|
||||
private static final int FP32_DENORMAL_MAGIC = 126 << 23;
|
||||
private static final float FP32_DENORMAL_FLOAT = Float.intBitsToFloat(FP32_DENORMAL_MAGIC);
|
||||
@@ -903,6 +904,9 @@ public final class Half extends Number implements Comparable<Half> {
|
||||
outM = m << 13;
|
||||
if (e == 0x1f) { // Infinite or NaN
|
||||
outE = 0xff;
|
||||
if (outM != 0) { // SNaNs are quieted
|
||||
outM |= FP32_QNAN_MASK;
|
||||
}
|
||||
} else {
|
||||
outE = e - FP16_EXPONENT_BIAS + FP32_EXPONENT_BIAS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user