From 810c86025633d5e15823d08fe7254539628abbdd Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Sun, 9 Jul 2017 14:14:36 +0100 Subject: [PATCH] Infinity is now a math constant --- lib/Math.hpp | 5 +++-- lib/MathInterpreter.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Math.hpp b/lib/Math.hpp index 6218f25..8bebbbb 100644 --- a/lib/Math.hpp +++ b/lib/Math.hpp @@ -72,8 +72,9 @@ namespace MATH_NAMESPACE DMat varToCorr(const DMat &var); // Constants - const double pi = 3.1415926535897932384626433832795028841970; - const double e = 2.7182818284590452353602874713526624977572; + constexpr double pi = 3.1415926535897932384626433832795028841970; + constexpr double e = 2.7182818284590452353602874713526624977572; + constexpr double inf = std::numeric_limits::infinity(); } diff --git a/lib/MathInterpreter.cpp b/lib/MathInterpreter.cpp index 192afe2..4787ab7 100644 --- a/lib/MathInterpreter.cpp +++ b/lib/MathInterpreter.cpp @@ -689,8 +689,8 @@ void MathInterpreter::compile(RunContext &context) { if (root_) { - context.addVariable("pi", Math::pi); - context.addVariable("inf", HUGE_VAL); + context.addVariable("pi", Math::pi); + context.addVariable("inf", Math::inf); ADD_STDMATH_FUNCS(context); root_->compile(program_, context); for (unsigned int i = 0; i < program_.size(); ++i)