[poincare] Integer: add safeguards on infinite Integer

This commit is contained in:
Émilie Feral
2018-08-14 18:20:12 +02:00
parent 503edea946
commit 7f0dc24f8d

View File

@@ -105,6 +105,10 @@ T NaturalIntegerAbstract::approximate() const {
* - the mantissa is the beginning of our BigInt, discarding the first bit
*/
if (isInfinity()) {
return INFINITY;
}
native_uint_t lastDigit = digit(m_numberOfDigits-1);
uint8_t numberOfBitsInLastDigit = log2(lastDigit);
@@ -155,6 +159,7 @@ T NaturalIntegerAbstract::approximate() const {
// Properties
int NaturalIntegerAbstract::NumberOfBase10Digits(const NaturalIntegerAbstract * i) {
assert(!i->isInfinity());
int numberOfDigits = 1;
Integer ref(i);
Integer base(10);