| 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); |
nothing calls this directly
no test coverage detected