MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / DoubleDebugString

Function DoubleDebugString

common/values/double_value.cc:39–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37using ::cel::well_known_types::ValueReflection;
38
39std::string DoubleDebugString(double value) {
40 if (std::isfinite(value)) {
41 if (std::floor(value) != value) {
42 // The double is not representable as a whole number, so use
43 // absl::StrCat which will add decimal places.
44 return absl::StrCat(value);
45 }
46 // absl::StrCat historically would represent 0.0 as 0, and we want the
47 // decimal places so ZetaSQL correctly assumes the type as double
48 // instead of int64.
49 std::string stringified = absl::StrCat(value);
50 if (!absl::StrContains(stringified, '.')) {
51 absl::StrAppend(&stringified, ".0");
52 } else {
53 // absl::StrCat has a decimal now? Use it directly.
54 }
55 return stringified;
56 }
57 if (std::isnan(value)) {
58 return "nan";
59 }
60 if (std::signbit(value)) {
61 return "-infinity";
62 }
63 return "+infinity";
64}
65
66} // namespace
67

Callers 1

DebugStringMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected