[apps/sequence] Cap the sum of terms to a maximum number of terms

Change-Id: Ib9abcdc92cef5e4e188a81c319b20be2c8b7ab72
This commit is contained in:
Émilie Feral
2017-04-17 14:17:45 +02:00
parent 6226daa04a
commit 8f2a6c3122
2 changed files with 4 additions and 0 deletions

View File

@@ -274,6 +274,9 @@ float Sequence::evaluateAtAbscissa(float x, Poincare::Context * context) const {
float Sequence::sumOfTermsBetweenAbscissa(float start, float end, Context * context) {
float result = 0.0f;
if (end-start > k_maxNumberOfTermsInSum) {
return NAN;
}
for (float i = roundf(start); i <= roundf(end); i = i + 1.0f) {
result += evaluateAtAbscissa(i, context);
}