@@ -69,6 +69,8 @@ Value::Value(SpecialValue specialValue) :
6969{
7070 if (specialValue == SpecialValue::Infinity)
7171 m_isInfinity = true ;
72+ else if (specialValue == SpecialValue::NegativeInfinity)
73+ m_isNegativeInfinity = true ;
7274 else if (specialValue == SpecialValue::NaN)
7375 m_isNaN = true ;
7476 else {
@@ -83,12 +85,18 @@ Value::Type Value::type() const
8385 return m_type;
8486}
8587
86- /* ! Returns true if the value is not finite . */
88+ /* ! Returns true if the value is infinity . */
8789bool Value::isInfinity () const
8890{
8991 return m_isInfinity;
9092}
9193
94+ /* ! Returns true if the value is negative infinity. */
95+ bool Value::isNegativeInfinity () const
96+ {
97+ return m_isNegativeInfinity;
98+ }
99+
92100/* ! Returns true if the value is NaN (Not a Number). */
93101bool Value::isNaN () const
94102{
@@ -126,6 +134,8 @@ float Value::toNumber() const
126134 case Type::Special:
127135 if (m_isInfinity)
128136 return std::numeric_limits<float >::infinity ();
137+ else if (m_isNegativeInfinity)
138+ return -std::numeric_limits<float >::infinity ();
129139 else
130140 return 0 ;
131141 }
@@ -169,6 +179,8 @@ std::string Value::toString() const
169179 case Type::Special:
170180 if (m_isInfinity)
171181 return " Infinity" ;
182+ else if (m_isNegativeInfinity)
183+ return " -Infinity" ;
172184 else
173185 return " NaN" ;
174186 }
@@ -199,6 +211,21 @@ float Value::stringToFloat(std::string s, bool *ok)
199211{
200212 if (ok)
201213 *ok = false ;
214+
215+ if (s == " Infinity" ) {
216+ if (ok)
217+ *ok = true ;
218+ return std::numeric_limits<float >::infinity ();
219+ } else if (s == " -Infinity" ) {
220+ if (ok)
221+ *ok = true ;
222+ return -std::numeric_limits<float >::infinity ();
223+ } else if (s == " NaN" ) {
224+ if (ok)
225+ *ok = true ;
226+ return 0 ;
227+ }
228+
202229 std::string digits = " 0123456789.eE+-" ;
203230 for (char c : s) {
204231 if (digits.find (c) == std::string::npos) {
0 commit comments