19#include "absl/status/status.h"
20#include "absl/strings/str_cat.h"
25constexpr double kInf = std::numeric_limits<double>::infinity();
29 if (!std::isfinite(d)) {
30 return absl::InvalidArgumentError(
31 absl::StrCat(
"Expected no NaN or inf but found value: ", d));
33 return absl::OkStatus();
37 if (std::isnan(
value)) {
38 return absl::InvalidArgumentError(
"Invalid NaN value");
41 return absl::InvalidArgumentError(
"Invalid positive infinite value");
44 return absl::InvalidArgumentError(
"Invalid negative infinite value");
47 return absl::InvalidArgumentError(
48 absl::StrCat(
"Invalid positive value = ",
value));
51 return absl::InvalidArgumentError(
52 absl::StrCat(
"Invalid negative value = ",
value));
54 return absl::OkStatus();
absl::Status CheckScalar(const double value, const DoubleOptions &options)
Checks value is not NaN and satisfies the additional conditions in options.
absl::Status CheckScalarNoNanNoInf(const double d)
In SWIG mode, we don't want anything besides these top-level includes.
bool allow_negative_infinity
bool allow_positive_infinity