// A NaN has a nonzero significand for (int i = 1; i <= 0x3ff; i++) { short binary16NaN = (short)(NAN_EXPONENT | i); assert isNaN(binary16NaN);
errors += testRoundTrip( binary16NaN);
errors += testRoundTrip((short)(SIGN_BIT | binary16NaN));
} return errors;
}
privatestaticint testRoundTrip(int i) { int errors = 0; short s = (short)i; float f = Float.float16ToFloat(s); short s2 = Float.floatToFloat16(f);
if (s != s2) {
errors++;
System.out.println("Roundtrip failure on NaN value " +
Integer.toHexString(0xFFFF & (int)s) + "\t got back " + Integer.toHexString(0xFFFF & (int)s2));
} return errors;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.