From 1b2c810eb29753604657b23755bf9c65382491ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 7 Nov 2018 11:32:57 +0100 Subject: [PATCH] [poincare] Delete useless method in Number --- poincare/include/poincare/number.h | 1 - poincare/src/number.cpp | 45 ------------------------------ 2 files changed, 46 deletions(-) diff --git a/poincare/include/poincare/number.h b/poincare/include/poincare/number.h index 999a703fc..8de3464bd 100644 --- a/poincare/include/poincare/number.h +++ b/poincare/include/poincare/number.h @@ -27,7 +27,6 @@ class Number : public Expression { public: Number(const NumberNode * node) : Expression(node) {} /* Return either a Rational, a Decimal or an Infinity. */ - static Number ParseDigits(const char * digits, size_t length); // TODO: remove me when homemade parser is ready static Number ParseNumber(const char * integralPart, size_t integralLength, const char * decimalPart, size_t decimalLenght, bool exponentIsNegative, const char * exponentPart, size_t exponentLength); /* Return either a Decimal or an Infinity or an Undefined. */ template static Number DecimalNumber(T f); diff --git a/poincare/src/number.cpp b/poincare/src/number.cpp index df38e7f93..0b0138c40 100644 --- a/poincare/src/number.cpp +++ b/poincare/src/number.cpp @@ -35,51 +35,6 @@ double NumberNode::doubleApproximation() const { } } -Number Number::ParseDigits(const char * digits, size_t length) { - assert(digits[0] != '-'); - const char * integral = digits; - size_t integralLength = length; - const char * fractional = strchr(digits, '.'); - size_t fractionalLength = 0; - if (fractional) { - integralLength = fractional - integral; - fractional++; - fractionalLength = length - integralLength - 1; - } - const char * exponent = strchr(digits, Ion::Charset::Exponent); - size_t exponentLength = 0; - if (exponent) { - integralLength = fractional ? integralLength : exponent - integral; - fractionalLength = fractional ? exponent - fractional : 0; - exponent++; - exponentLength = length - integralLength - fractionalLength - (fractional ? 2 : 1); - } - // Integer - if (exponentLength == 0 && fractionalLength == 0) { - Integer i(integral, integralLength, false); - if (!i.isInfinity()) { - return Rational(i); - } - } - int exp; - // Avoid overflowing int - if (exponentLength < Decimal::k_maxExponentLength) { - exp = Decimal::Exponent(integral, integralLength, fractional, fractionalLength, exponent, exponentLength); - } else { - assert(exponent); - exp = exponent[0] == '-' ? -1 : 1; - } - // Avoid Decimal with exponent > k_maxExponentLength - if (exponentLength >= Decimal::k_maxExponentLength || exp > Decimal::k_maxExponent || exp < -Decimal::k_maxExponent) { - if (exp < 0) { - return Decimal(0.0); - } else { - return Infinity(false); - } - } - return Decimal(integral, integralLength, fractional, fractionalLength, exp); -} - Number Number::ParseNumber(const char * integralPart, size_t integralLength, const char * decimalPart, size_t decimalLenght, bool exponentIsNegative, const char * exponentPart, size_t exponentLength) { // Integer if (exponentLength == 0 && decimalLenght == 0) {