@Test public void testBuildFloat() { assertThat(ParserHelper.buildFloat(0, 0), is(0.0f)); assertThat(ParserHelper.buildFloat(1, 129), is(Float.POSITIVE_INFINITY)); assertThat(ParserHelper.buildFloat(-1, 128), is(Float.NEGATIVE_INFINITY)); assertThat(ParserHelper.buildFloat(1, 0), is(1f)); assertThat(ParserHelper.buildFloat(1, 2), is(100f)); assertThat(ParserHelper.buildFloat(100000000, 1), is(1.0E9F)); }
public static float buildFloat(int mant, int exp) { if (exp < -125 || mant == 0) { return 0.0f; } if (exp >= 128) { return (mant > 0) ? Float.POSITIVE_INFINITY : Float.NEGATIVE_INFINITY; } if (exp == 0) { return mant; } if (mant >= (1 << 26)) { mant++; } return (float) ((exp > 0) ? mant * pow10[exp] : mant / pow10[-exp]); }
ParserHelper { public static float buildFloat(int mant, int exp) { if (exp < -125 || mant == 0) { return 0.0f; } if (exp >= 128) { return (mant > 0) ? Float.POSITIVE_INFINITY : Float.NEGATIVE_INFINITY; } if (exp == 0) { return mant; } if (mant >= (1 << 26)) { mant++; } return (float) ((exp > 0) ? mant * pow10[exp] : mant / pow10[-exp]); } }
ParserHelper { public static float buildFloat(int mant, int exp) { if (exp < -125 || mant == 0) { return 0.0f; } if (exp >= 128) { return (mant > 0) ? Float.POSITIVE_INFINITY : Float.NEGATIVE_INFINITY; } if (exp == 0) { return mant; } if (mant >= (1 << 26)) { mant++; } return (float) ((exp > 0) ? mant * pow10[exp] : mant / pow10[-exp]); } ParserHelper(CharSequence s, int pos); }
ParserHelper { public static float buildFloat(int mant, int exp) { if (exp < -125 || mant == 0) { return 0.0f; } if (exp >= 128) { return (mant > 0) ? Float.POSITIVE_INFINITY : Float.NEGATIVE_INFINITY; } if (exp == 0) { return mant; } if (mant >= (1 << 26)) { mant++; } return (float) ((exp > 0) ? mant * pow10[exp] : mant / pow10[-exp]); } ParserHelper(CharSequence s, int pos); void skipWhitespace(); void skipNumberSeparator(); void advance(); float parseFloat(); static float buildFloat(int mant, int exp); float nextFloat(); }
ParserHelper { public static float buildFloat(int mant, int exp) { if (exp < -125 || mant == 0) { return 0.0f; } if (exp >= 128) { return (mant > 0) ? Float.POSITIVE_INFINITY : Float.NEGATIVE_INFINITY; } if (exp == 0) { return mant; } if (mant >= (1 << 26)) { mant++; } return (float) ((exp > 0) ? mant * pow10[exp] : mant / pow10[-exp]); } ParserHelper(CharSequence s, int pos); void skipWhitespace(); void skipNumberSeparator(); void advance(); float parseFloat(); static float buildFloat(int mant, int exp); float nextFloat(); public int pos; }