fix float to integer conversion

Java requires that NaNs be converted to zero and that numbers at or
beyond the limits of integer representation be clamped to the largest
or smallest value that can be represented, respectively.
This commit is contained in:
Joel Dice
2012-08-12 14:31:58 -06:00
parent 47503854d5
commit b98abe3f94
6 changed files with 132 additions and 10 deletions

View File

@ -14,6 +14,10 @@ public final class Float extends Number {
public static final Class TYPE = Class.forCanonicalName("F");
private static final int EXP_BIT_MASK = 0x7F800000;
private static final int SIGNIF_BIT_MASK = 0x007FFFFF;
public static final float NEGATIVE_INFINITY = -1.0f / 0.0f;
public static final float POSITIVE_INFINITY = 1.0f / 0.0f;
public static final float NaN = 0.0f / 0.0f;
private final float value;