File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,23 @@ std::u16string Value::toUtf16() const
232232 return utf8::utf8to16 (toString ());
233233}
234234
235+ /* ! Adds the given value to the value. */
236+ void Value::add (const Value &v)
237+ {
238+ if ((m_isInfinity && v.m_isNegativeInfinity ) || (m_isNegativeInfinity && v.m_isInfinity )) {
239+ m_isInfinity = false ;
240+ m_isNegativeInfinity = false ;
241+ m_isNaN = true ;
242+ } else if (m_isInfinity || v.m_isInfinity ) {
243+ m_type = Type::Special;
244+ m_isInfinity = true ;
245+ } else if (m_isNegativeInfinity || v.m_isNegativeInfinity ) {
246+ m_type = Type::Special;
247+ m_isNegativeInfinity = true ;
248+ }
249+ m_value = toDouble () + v.toDouble ();
250+ }
251+
235252bool Value::stringsEqual (std::u16string s1, std::u16string s2)
236253{
237254 std::transform (s1.begin (), s1.end (), s1.begin (), ::tolower);
Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ class LIBSCRATCHCPP_EXPORT Value
5555 std::string toString () const ;
5656 std::u16string toUtf16 () const ;
5757
58+ void add (const Value &v);
59+
5860 inline const Value &operator =(float v)
5961 {
6062 m_type = Type::Number;
You can’t perform that action at this time.
0 commit comments