public static FloatToken int2float( IntToken term, IntToken precision, IntToken exponent, TermContext context) { return FloatToken.of( new BigFloat( term.bigIntegerValue(), new BinaryMathContext(precision.intValue(), exponent.intValue())), exponent.intValue()); }
/** * Rounds {@code term} to the specfiied precision and exponent range. * * <p>Method is undefined if either integer is less than 2 because 2 is the minimum precision and * exponent. Two exponents must be used to store zero/subnormal/infinity/nan, so 4 is the minimum * number of distinct exponents a float can have. MPFR does not support floats with 1 bit of * precision. bits of the float. */ public static FloatToken round( FloatToken term, IntToken precision, IntToken exponent, TermContext context) { if (precision.intValue() < 2 || exponent.intValue() < 2) { return null; } return FloatToken.of( term.bigFloatValue() .round(new BinaryMathContext(precision.intValue(), exponent.intValue())), exponent.intValue()); }
public static FloatToken minValue( IntToken precision, IntToken exponentBits, TermContext context) { BinaryMathContext mc = new BinaryMathContext(precision.intValue(), exponentBits.intValue()); return FloatToken.of(BigFloat.minValue(mc.precision, mc.minExponent), exponentBits.intValue()); }
public static FloatToken root(FloatToken term1, IntToken term2, TermContext context) { return FloatToken.of( term1.bigFloatValue().root(term2.intValue(), getMathContext(term1)), term1.exponent()); }