@Test public void testFormat() throws Exception { try { me.setGroupingSeparator(' '); assertEquals("1", me.format(1d, NumeralBase.bin)); assertEquals("10", me.format(2d, NumeralBase.bin)); assertEquals("11", me.format(3d, NumeralBase.bin)); assertEquals("100", me.format(4d, NumeralBase.bin)); assertEquals("101", me.format(5d, NumeralBase.bin)); assertEquals("110", me.format(6d, NumeralBase.bin)); assertEquals("111", me.format(7d, NumeralBase.bin)); assertEquals("1000", me.format(8d, NumeralBase.bin)); assertEquals("1001", me.format(9d, NumeralBase.bin)); assertEquals("1 0001", me.format(17d, NumeralBase.bin)); assertEquals("1 0100", me.format(20d, NumeralBase.bin)); assertEquals("1 0100", me.format(20d, NumeralBase.bin)); assertEquals("1 1111", me.format(31d, NumeralBase.bin)); me.setPrecision(10); assertEquals("111 1111 0011 0110", me.format(32566d, NumeralBase.bin)); assertEquals("100.0100110011", me.format(4.3d, NumeralBase.bin)); assertEquals("1 0001 0101 0011.01010101101", me.format(4435.33423d, NumeralBase.bin)); assertEquals("1100.01010101011", me.format(12.3333d, NumeralBase.bin)); assertEquals("1 0011 1101 1110 0100 0011 0101 0101.00011111", me.format(333333333.1212213321d, NumeralBase.bin)); assertEquals("0.EEEEEEEEEEF", me.format(14d / 15d, NumeralBase.hex)); assertEquals("7F 36", me.format(32566d, NumeralBase.hex)); assertEquals("24", me.format(36d, NumeralBase.hex)); assertEquals("8", me.format(8d, NumeralBase.hex)); assertEquals("1 3D", me.format(317d, NumeralBase.hex)); assertEquals("13 DE 43 55.1F085BEF", me.format(333333333.1212213321d, NumeralBase.hex)); assertEquals("D 25 0F 77 0A.6F7319", me.format(56456345354.43534534523459999d, NumeralBase.hex)); assertEquals("3 E7.4CCCCCCCCCD", me.format(999.3d, NumeralBase.hex)); me.setPrecision(NumberFormatter.MAX_PRECISION); assertEquals("6.CCDA6A054226DB6E-19", me.format(0.00000000000000000000009d, NumeralBase.hex)); assertEquals("A.E15D766ED03E2BEE-20", me.format(0.000000000000000000000009d, NumeralBase.hex)); } finally { me.setGroupingSeparator(NumberFormatter.NO_GROUPING); } assertEquals("1", me.format(1d, NumeralBase.bin)); assertEquals("10", me.format(2d, NumeralBase.bin)); assertEquals("11", me.format(3d, NumeralBase.bin)); assertEquals("100", me.format(4d, NumeralBase.bin)); assertEquals("101", me.format(5d, NumeralBase.bin)); assertEquals("110", me.format(6d, NumeralBase.bin)); assertEquals("111", me.format(7d, NumeralBase.bin)); assertEquals("1000", me.format(8d, NumeralBase.bin)); assertEquals("1001", me.format(9d, NumeralBase.bin)); assertEquals("10001", me.format(17d, NumeralBase.bin)); assertEquals("10100", me.format(20d, NumeralBase.bin)); assertEquals("10100", me.format(20d, NumeralBase.bin)); assertEquals("11111", me.format(31d, NumeralBase.bin)); assertEquals("111111100110110", me.format(32566d, NumeralBase.bin)); assertEquals("7F36", me.format(32566d, NumeralBase.hex)); assertEquals("24", me.format(36d, NumeralBase.hex)); assertEquals("8", me.format(8d, NumeralBase.hex)); assertEquals("13D", me.format(317d, NumeralBase.hex)); }
@Nonnull public String format(double value) { return format(value, numeralBase); }
JsclMathEngine implements MathEngine { @Nonnull public String format(double value) { return format(value, numeralBase); } }
JsclMathEngine implements MathEngine { @Nonnull public String format(double value) { return format(value, numeralBase); } JsclMathEngine(); }
JsclMathEngine implements MathEngine { @Nonnull public String format(double value) { return format(value, numeralBase); } JsclMathEngine(); @Nonnull static JsclMathEngine getInstance(); @Nonnull String evaluate(@Nonnull String expression); @Nonnull String simplify(@Nonnull String expression); @Nonnull String elementary(@Nonnull String expression); @Nonnull Generic evaluateGeneric(@Nonnull String expression); @Nonnull Generic simplifyGeneric(@Nonnull String expression); @Nonnull Generic elementaryGeneric(@Nonnull String expression); @Nonnull MathRegistry<Function> getFunctionsRegistry(); @Nonnull MathRegistry<Operator> getOperatorsRegistry(); @Nonnull MathRegistry<Operator> getPostfixFunctionsRegistry(); @Nonnull AngleUnit getAngleUnits(); void setAngleUnits(@Nonnull AngleUnit angleUnits); @Nonnull NumeralBase getNumeralBase(); void setNumeralBase(@Nonnull NumeralBase numeralBase); @Nonnull MathRegistry<IConstant> getConstantsRegistry(); @Nonnull String format(double value); @Nonnull String format(double value, @Nonnull NumeralBase nb); @Override String format(@Nonnull BigInteger value); @Nonnull String format(@Nonnull BigInteger value, @Nonnull NumeralBase nb); @Nonnull MessageRegistry getMessageRegistry(); void setMessageRegistry(@Nonnull MessageRegistry messageRegistry); @Nonnull @Override String format(@Nonnull String value, @Nonnull NumeralBase nb); @Nonnull String insertSeparators(@Nonnull String value, @Nonnull NumeralBase nb); void setPrecision(int precision); void setNotation(int notation); char getGroupingSeparator(); void setGroupingSeparator(char separator); }
JsclMathEngine implements MathEngine { @Nonnull public String format(double value) { return format(value, numeralBase); } JsclMathEngine(); @Nonnull static JsclMathEngine getInstance(); @Nonnull String evaluate(@Nonnull String expression); @Nonnull String simplify(@Nonnull String expression); @Nonnull String elementary(@Nonnull String expression); @Nonnull Generic evaluateGeneric(@Nonnull String expression); @Nonnull Generic simplifyGeneric(@Nonnull String expression); @Nonnull Generic elementaryGeneric(@Nonnull String expression); @Nonnull MathRegistry<Function> getFunctionsRegistry(); @Nonnull MathRegistry<Operator> getOperatorsRegistry(); @Nonnull MathRegistry<Operator> getPostfixFunctionsRegistry(); @Nonnull AngleUnit getAngleUnits(); void setAngleUnits(@Nonnull AngleUnit angleUnits); @Nonnull NumeralBase getNumeralBase(); void setNumeralBase(@Nonnull NumeralBase numeralBase); @Nonnull MathRegistry<IConstant> getConstantsRegistry(); @Nonnull String format(double value); @Nonnull String format(double value, @Nonnull NumeralBase nb); @Override String format(@Nonnull BigInteger value); @Nonnull String format(@Nonnull BigInteger value, @Nonnull NumeralBase nb); @Nonnull MessageRegistry getMessageRegistry(); void setMessageRegistry(@Nonnull MessageRegistry messageRegistry); @Nonnull @Override String format(@Nonnull String value, @Nonnull NumeralBase nb); @Nonnull String insertSeparators(@Nonnull String value, @Nonnull NumeralBase nb); void setPrecision(int precision); void setNotation(int notation); char getGroupingSeparator(); void setGroupingSeparator(char separator); static final AngleUnit DEFAULT_ANGLE_UNITS; static final NumeralBase DEFAULT_NUMERAL_BASE; static final char GROUPING_SEPARATOR_DEFAULT; }