[poincare] Delete useless method in Number

This commit is contained in:
Émilie Feral
2018-11-07 11:32:57 +01:00
parent 0e5da52d3d
commit 1b2c810eb2
2 changed files with 0 additions and 46 deletions

View File

@@ -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 <typename T> static Number DecimalNumber(T f);

View File

@@ -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) {