[poincare] PrintFloat: remove never used addition. max(0, negative

number) is always 0
This commit is contained in:
Émilie Feral
2019-09-04 10:37:44 +02:00
parent bd8d3b3685
commit 6bc80a4f21

View File

@@ -19,7 +19,6 @@ extern "C" {
namespace Poincare {
static inline int minInt(int x, int y) { return x < y ? x : y; }
static inline int maxInt(int x, int y) { return x > y ? x : y; }
PrintFloat::Long::Long(int64_t i) :
m_negative(i < 0)
@@ -242,14 +241,15 @@ int PrintFloat::ConvertFloatToTextPrivate(T f, char * buffer, int bufferSize, in
if (exponentInBase10 >= 0) {
numberOfCharsForMantissaWithoutSign = numberOfSignificantDigits;
} else {
/* exponentInBase10 < 0, so we add |exponentInBase10| to count 0 added
* before significant digits */
numberOfCharsForMantissaWithoutSign = numberOfSignificantDigits - exponentInBase10;
}
} else if (mode == Preferences::PrintFloatMode::Scientific) {
numberOfCharsForMantissaWithoutSign = numberOfSignificantDigits;
} else {
assert(mode == Preferences::PrintFloatMode::Engineering);
numberOfCharsForMantissaWithoutSign = numberOfSignificantDigits + maxInt(0, (numberOfSignificantDigits%3) - numberOfSignificantDigits + 1);
assert(numberOfCharsForMantissaWithoutSign <= numberOfSignificantDigits);
numberOfCharsForMantissaWithoutSign = numberOfSignificantDigits;
}
/* The number of digits in a mantissa is capped because the maximal int64_t is