diff --git a/src/main/java/org/solovyev/android/calculator/model/CalculatorEngine.java b/src/main/java/org/solovyev/android/calculator/model/CalculatorEngine.java
index b4f5ddda..e51ceeb5 100644
--- a/src/main/java/org/solovyev/android/calculator/model/CalculatorEngine.java
+++ b/src/main/java/org/solovyev/android/calculator/model/CalculatorEngine.java
@@ -81,11 +81,6 @@ public enum CalculatorEngine {
this.engine.setUseGroupingSeparator(true);
}
- @NotNull
- public String format(@NotNull Double value, boolean round) {
- return getEngine().format(value, round);
- }
-
public static class Result {
@NotNull
diff --git a/src/main/java/org/solovyev/android/calculator/model/NumberBuilder.java b/src/main/java/org/solovyev/android/calculator/model/NumberBuilder.java
index 52ba57a2..db3d301e 100644
--- a/src/main/java/org/solovyev/android/calculator/model/NumberBuilder.java
+++ b/src/main/java/org/solovyev/android/calculator/model/NumberBuilder.java
@@ -172,11 +172,11 @@ public class NumberBuilder {
indexOfE = number.indexOf('E');
}
if (indexOfE < 0) {
- formattedNumber = Numeric.toString(toDouble(number, nb), nb);
+ formattedNumber = toString(toDouble(number, nb), nb);
} else {
final String part;
if (indexOfDot != 0) {
- part = Numeric.toString(toDouble(number.substring(0, indexOfE), nb), nb);
+ part = toString(toDouble(number.substring(0, indexOfE), nb), nb);
} else {
part = "";
}
@@ -185,14 +185,14 @@ public class NumberBuilder {
} else {
final String integerPart;
if (indexOfDot != 0) {
- integerPart = Numeric.toString(toDouble(number.substring(0, indexOfDot), nb), nb);
+ integerPart = toString(toDouble(number.substring(0, indexOfDot), nb), nb);
} else {
integerPart = "";
}
formattedNumber = integerPart + number.substring(indexOfDot);
}
} else {
- formattedNumber = Numeric.toString(toDouble(number, nb), nb);
+ formattedNumber = toString(toDouble(number, nb), nb);
}
if (numberOffset != null) {
@@ -205,6 +205,11 @@ public class NumberBuilder {
return result;
}
+ @NotNull
+ private static String toString(@NotNull Double value, @NotNull NumeralBase nb) {
+ return CalculatorEngine.instance.getEngine().format(value, nb);
+ }
+
public boolean isHexMode() {
return nb == NumeralBase.hex || ( nb == null && defaultNumeralBase == NumeralBase.hex);
}
diff --git a/src/test/java/org/solovyev/android/calculator/TextHighlighterTest.java b/src/test/java/org/solovyev/android/calculator/TextHighlighterTest.java
index ab143cdf..ce81a80e 100644
--- a/src/test/java/org/solovyev/android/calculator/TextHighlighterTest.java
+++ b/src/test/java/org/solovyev/android/calculator/TextHighlighterTest.java
@@ -84,8 +84,8 @@ public class TextHighlighterTest {
Assert.assertEquals("0x:6F", textHighlighter.process("0x:6F.B").toString());
Assert.assertEquals("0x:6F", textHighlighter.process("0x:006F.B").toString());
Assert.assertEquals("0x:0", textHighlighter.process("0x:0").toString());
- Assert.assertEquals("0x:FF33233FFE", textHighlighter.process("0x:FF33233FFE").toString());
- Assert.assertEquals("0x:FF33233FFE", textHighlighter.process("0x:FF33 233 FFE").toString());
+ Assert.assertEquals("0x:FF 33 23 3F FE", textHighlighter.process("0x:FF33233FFE").toString());
+ Assert.assertEquals("0x:FF 33 23 3F FE", textHighlighter.process("0x:FF33 233 FFE").toString());
final MathEngine me = CalculatorEngine.instance.getEngine();
try {
@@ -104,25 +104,25 @@ public class TextHighlighterTest {
me.setNumeralBase(NumeralBase.dec);
}
- Assert.assertEquals("0b:110101", textHighlighter.process("0b:110101").toString());
- Assert.assertEquals("0b:110101", textHighlighter.process("0b:110101.").toString());
- Assert.assertEquals("0b:110101", textHighlighter.process("0b:110101.101").toString());
- Assert.assertEquals("0b:11010100", textHighlighter.process("0b:11010100.1").toString());
- Assert.assertEquals("0b:110101", textHighlighter.process("0b:110101.0").toString());
+ Assert.assertEquals("0b:11 0101", textHighlighter.process("0b:110101").toString());
+ Assert.assertEquals("0b:11 0101", textHighlighter.process("0b:110101.").toString());
+ Assert.assertEquals("0b:11 0101", textHighlighter.process("0b:110101.101").toString());
+ Assert.assertEquals("0b:1101 0100", textHighlighter.process("0b:11010100.1").toString());
+ Assert.assertEquals("0b:11 0101", textHighlighter.process("0b:110101.0").toString());
Assert.assertEquals("0b:0", textHighlighter.process("0b:0").toString());
- Assert.assertEquals("0b:1010100101111010101001", textHighlighter.process("0b:1010100101111010101001").toString());
- Assert.assertEquals("0b:1010100101111010101001", textHighlighter.process("0b:101 010 01 0 111 1 0 10101001").toString());
+ Assert.assertEquals("0b:10 1010 0101 1110 1010 1001", textHighlighter.process("0b:1010100101111010101001").toString());
+ Assert.assertEquals("0b:10 1010 0101 1110 1010 1001", textHighlighter.process("0b:101 010 01 0 111 1 0 10101001").toString());
try {
me.setNumeralBase(NumeralBase.bin);
- Assert.assertEquals("110101", textHighlighter.process("110101").toString());
- Assert.assertEquals("110101", textHighlighter.process("110101.").toString());
- Assert.assertEquals("110101", textHighlighter.process("110101.101").toString());
- Assert.assertEquals("11010100", textHighlighter.process("11010100.1").toString());
- Assert.assertEquals("110101", textHighlighter.process("110101.0").toString());
+ Assert.assertEquals("11 0101", textHighlighter.process("110101").toString());
+ Assert.assertEquals("11 0101", textHighlighter.process("110101.").toString());
+ Assert.assertEquals("11 0101", textHighlighter.process("110101.101").toString());
+ Assert.assertEquals("1101 0100", textHighlighter.process("11010100.1").toString());
+ Assert.assertEquals("11 0101", textHighlighter.process("110101.0").toString());
Assert.assertEquals("0", textHighlighter.process("0").toString());
- Assert.assertEquals("1010100101111010101001", textHighlighter.process("1010100101111010101001").toString());
- Assert.assertEquals("1010100101111010101001", textHighlighter.process("101 010 01 0 111 1 0 10101001").toString());
+ Assert.assertEquals("10 1010 0101 1110 1010 1001", textHighlighter.process("1010100101111010101001").toString());
+ Assert.assertEquals("10 1010 0101 1110 1010 1001", textHighlighter.process("101 010 01 0 111 1 0 10101001").toString());
} finally {
me.setNumeralBase(NumeralBase.dec);
}
diff --git a/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java b/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java
index 3e04b076..b5e37602 100644
--- a/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java
+++ b/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java
@@ -388,7 +388,7 @@ public class CalculatorEngineTest {
}
cm.getEngine().setNumeralBase(NumeralBase.hex);
- Assert.assertEquals("637B", cm.evaluate(JsclOperation.numeric, "56CE+CAD").getResult());
+ Assert.assertEquals("63 7B", cm.evaluate(JsclOperation.numeric, "56CE+CAD").getResult());
Assert.assertEquals("E", cm.evaluate(JsclOperation.numeric, "E").getResult());
} finally {
cm.setNumeralBase(defaultNumeralBase);
diff --git a/src/test/java/org/solovyev/android/calculator/model/FromJsclSimplifyTextProcessorTest.java b/src/test/java/org/solovyev/android/calculator/model/FromJsclSimplifyTextProcessorTest.java
index e3d0248d..b6449883 100644
--- a/src/test/java/org/solovyev/android/calculator/model/FromJsclSimplifyTextProcessorTest.java
+++ b/src/test/java/org/solovyev/android/calculator/model/FromJsclSimplifyTextProcessorTest.java
@@ -66,7 +66,7 @@ public class FromJsclSimplifyTextProcessorTest {
Assert.assertEquals("20x", tp.process("20x"));
Assert.assertEquals("2×0x3", tp.process("2*0x3"));
Assert.assertEquals("2×0x:3", tp.process("2*0x:3"));
- Assert.assertEquals("0x:3000000", tp.process("0x:3 000 000.00000000000001"));
+ Assert.assertEquals("0x:3 00 00 00", tp.process("0x:3 000 000.00000000000001"));
}
}