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

Method WriteFloatImpl

library/cpp/json/ordered_maps/json_ordered.cpp:258–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256
257 template <class TFloat>
258 TValueContext TBuf::WriteFloatImpl(TFloat f, EFloatToStringMode mode, int ndigits) {
259 char buf[512]; // enough to hold most floats, the same buffer is used in FloatToString implementation
260 if (Y_UNLIKELY(!IsValidFloat(f))) {
261 if (WriteNanAsString) {
262 const size_t size = FloatToString(f, buf, Y_ARRAY_SIZE(buf));
263 WriteString(TStringBuf(buf, size));
264 return TValueContext(*this);
265 } else {
266 ythrow TError() << "JSON writer: invalid float value: " << FloatToString(f);
267 }
268 }
269 size_t len = FloatToString(f, buf, Y_ARRAY_SIZE(buf), mode, ndigits);
270 UnsafeWriteValue(buf, len);
271 return TValueContext(*this);
272 }
273
274 TValueContext TBuf::WriteFloat(float f, EFloatToStringMode mode, int ndigits) {
275 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