1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * Represents the a number as the result of evaluating an Expr
11 #include "mozilla/FloatingPoint.h"
13 #include "txExprResult.h"
20 * Creates a new NumberResult with the value of the given double parameter
21 * @param dbl the double to use for initialization of this NumberResult's value
23 NumberResult::NumberResult(double aValue
, txResultRecycler
* aRecycler
)
24 : txAExprResult(aRecycler
), value(aValue
) {} //-- NumberResult
27 * Virtual Methods from ExprResult
30 short NumberResult::getResultType() {
31 return txAExprResult::NUMBER
;
34 void NumberResult::stringValue(nsString
& aResult
) {
35 txDouble::toString(value
, aResult
);
38 const nsString
* NumberResult::stringValuePointer() { return nullptr; }
40 bool NumberResult::booleanValue() {
42 // As per the XPath spec, the boolean value of a number is true if and only if
43 // it is neither positive 0 nor negative 0 nor NaN
44 return (bool)(value
!= 0.0 && !std::isnan(value
));
48 double NumberResult::numberValue() { return this->value
; } //-- numberValue