| 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 | |