number formatting
This commit is contained in:
parent
c1b83c5b99
commit
e483ac6af5
@ -81,11 +81,6 @@ public enum CalculatorEngine {
|
|||||||
this.engine.setUseGroupingSeparator(true);
|
this.engine.setUseGroupingSeparator(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public String format(@NotNull Double value, boolean round) {
|
|
||||||
return getEngine().format(value, round);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Result {
|
public static class Result {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -172,11 +172,11 @@ public class NumberBuilder {
|
|||||||
indexOfE = number.indexOf('E');
|
indexOfE = number.indexOf('E');
|
||||||
}
|
}
|
||||||
if (indexOfE < 0) {
|
if (indexOfE < 0) {
|
||||||
formattedNumber = Numeric.toString(toDouble(number, nb), nb);
|
formattedNumber = toString(toDouble(number, nb), nb);
|
||||||
} else {
|
} else {
|
||||||
final String part;
|
final String part;
|
||||||
if (indexOfDot != 0) {
|
if (indexOfDot != 0) {
|
||||||
part = Numeric.toString(toDouble(number.substring(0, indexOfE), nb), nb);
|
part = toString(toDouble(number.substring(0, indexOfE), nb), nb);
|
||||||
} else {
|
} else {
|
||||||
part = "";
|
part = "";
|
||||||
}
|
}
|
||||||
@ -185,14 +185,14 @@ public class NumberBuilder {
|
|||||||
} else {
|
} else {
|
||||||
final String integerPart;
|
final String integerPart;
|
||||||
if (indexOfDot != 0) {
|
if (indexOfDot != 0) {
|
||||||
integerPart = Numeric.toString(toDouble(number.substring(0, indexOfDot), nb), nb);
|
integerPart = toString(toDouble(number.substring(0, indexOfDot), nb), nb);
|
||||||
} else {
|
} else {
|
||||||
integerPart = "";
|
integerPart = "";
|
||||||
}
|
}
|
||||||
formattedNumber = integerPart + number.substring(indexOfDot);
|
formattedNumber = integerPart + number.substring(indexOfDot);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
formattedNumber = Numeric.toString(toDouble(number, nb), nb);
|
formattedNumber = toString(toDouble(number, nb), nb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numberOffset != null) {
|
if (numberOffset != null) {
|
||||||
@ -205,6 +205,11 @@ public class NumberBuilder {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static String toString(@NotNull Double value, @NotNull NumeralBase nb) {
|
||||||
|
return CalculatorEngine.instance.getEngine().format(value, nb);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isHexMode() {
|
public boolean isHexMode() {
|
||||||
return nb == NumeralBase.hex || ( nb == null && defaultNumeralBase == NumeralBase.hex);
|
return nb == NumeralBase.hex || ( nb == null && defaultNumeralBase == NumeralBase.hex);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user