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

Method WriteFloatImpl

library/cpp/json/writer/json.cpp:251–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249
250 template <class TFloat>
251 TValueContext TBuf::WriteFloatImpl(TFloat f, EFloatToStringMode mode, int ndigits) {
252 char buf[512]; // enough to hold most floats, the same buffer is used in FloatToString implementation
253 if (Y_UNLIKELY(!IsValidFloat(f))) {
254 if (WriteNanAsString) {
255 const size_t size = FloatToString(f, buf, Y_ARRAY_SIZE(buf));
256 WriteString(TStringBuf(buf, size));
257 return TValueContext(*this);
258 } else {
259 ythrow TError() << "JSON writer: invalid float value: " << FloatToString(f);
260 }
261 }
262 size_t len = FloatToString(f, buf, Y_ARRAY_SIZE(buf), mode, ndigits);
263 UnsafeWriteValue(buf, len);
264 return TValueContext(*this);
265 }
266
267 TValueContext TBuf::WriteFloat(float f, EFloatToStringMode mode, int ndigits) {
268 return WriteFloatImpl(f, mode, ndigits);

Callers

nothing calls this directly

Calls 4

IsValidFloatFunction · 0.85
TValueContextClass · 0.70
FloatToStringFunction · 0.50
WriteStringFunction · 0.50

Tested by

no test coverage detected