MCPcopy Create free account
hub / github.com/catboost/catboost / FloatToStringWithNanInf

Function FloatToStringWithNanInf

library/cpp/yson/writer.cpp:112–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110 }
111
112 TString FloatToStringWithNanInf(double value) {
113 if (std::isfinite(value)) {
114 return ::ToString(value);
115 }
116
117 static const TStringBuf nanLiteral = "%nan";
118 static const TStringBuf infLiteral = "%inf";
119 static const TStringBuf negativeInfLiteral = "%-inf";
120
121 TStringBuf str;
122 if (std::isnan(value)) {
123 str = nanLiteral;
124 } else if (value > 0) {
125 str = infLiteral;
126 } else {
127 str = negativeInfLiteral;
128 }
129 return TString(str.data(), str.size());
130 }
131
132 }
133

Callers 1

OnDoubleScalarMethod · 0.85

Calls 5

ToStringFunction · 0.70
isfiniteFunction · 0.50
isnanFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected