From 892dd2de4f29e416efa48a8c70ebb756407385d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Thu, 3 Jan 2019 11:50:06 +0100 Subject: [PATCH] [apps/poincare] Clean some comments --- apps/calculation/calculation_store.cpp | 8 ++++---- poincare/include/poincare/decimal.h | 2 +- poincare/include/poincare/number.h | 4 +++- poincare/src/number.cpp | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/calculation/calculation_store.cpp b/apps/calculation/calculation_store.cpp index b3f747c9d..64813e188 100644 --- a/apps/calculation/calculation_store.cpp +++ b/apps/calculation/calculation_store.cpp @@ -92,10 +92,10 @@ Expression CalculationStore::ansExpression(Context * context) { } Calculation * lastCalculation = calculationAtIndex(numberOfCalculations()-1); /* Special case: the exact output is a Store/Equal expression. - * Store/Equal expression must be final root of an expression. - * To avoid turning 'ans->A' in '2->A->A' (or 2->A=A) which cannot be parsed), - * ans is replaced by the approximation output in when any Store or Equal - * expression appears.*/ + * Store/Equal expression can only be at the root of an expression. + * To avoid turning 'ans->A' in '2->A->A' or '2=A->A' (which cannot be + * parsed), ans is replaced by the approximation output when any Store or + * Equal expression appears. */ bool exactOuptutInvolvesStoreEqual = lastCalculation->exactOutput().recursivelyMatches([](const Expression e, Context & context, bool replaceSymbols) { return e.type() == ExpressionNode::Type::Store || e.type() == ExpressionNode::Type::Equal; }, *context, false); diff --git a/poincare/include/poincare/decimal.h b/poincare/include/poincare/decimal.h index 267430441..adc0ecf31 100644 --- a/poincare/include/poincare/decimal.h +++ b/poincare/include/poincare/decimal.h @@ -6,7 +6,7 @@ namespace Poincare { -/* A decimal as 0.01234 is stored that way: +/* The decimal 0.01234 is stored as: * - bool m_negative = false * - int m_exponent = -2 * - int m_numberOfDigitsInMantissa = 1 diff --git a/poincare/include/poincare/number.h b/poincare/include/poincare/number.h index 557fa5b0b..0047c6c22 100644 --- a/poincare/include/poincare/number.h +++ b/poincare/include/poincare/number.h @@ -11,7 +11,9 @@ namespace Poincare { * - Float * - Decimal * - Infinity - */ + * + * Before being approximated, an expression should be reduced and thus should + * not contain any Decimal. */ class Rational; diff --git a/poincare/src/number.cpp b/poincare/src/number.cpp index e991c254a..bfc42b518 100644 --- a/poincare/src/number.cpp +++ b/poincare/src/number.cpp @@ -91,7 +91,8 @@ Number Number::BinaryOperation(const Number & i, const Number & j, RationalBinar return a; } } - // one of the operand is Undefined/Infinity/Float or the Rational addition overflowed + /* At least one of the operands is Undefined/Infinity/Float, or the Rational + * addition overflowed */ double a = doubleOp(i.node()->doubleApproximation(), j.node()->doubleApproximation()); return FloatNumber(a); }