Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fea7e9f2 authored by xueliang.zhong's avatar xueliang.zhong Committed by android-build-merger
Browse files

Merge "Quiet SNaN inputs in Half.toFloat()"

am: a879fd8b

Change-Id: I9ad4e399a81121ec0e59d8aa1af4cd05866c12cb
parents e9dc415e a879fd8b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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;
            }