MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / dump_float

Function dump_float

3rd/nlohmann_json/single_include/nlohmann/json.hpp:17192–17211  ·  view source on GitHub ↗

! @brief dump a floating-point number Dump a given floating-point number to output stream @a o. Works internally with @a number_buffer. @param[in] x floating-point number to dump */

Source from the content-addressed store, hash-verified

17190 @param[in] x floating-point number to dump
17191 */
17192 void dump_float(number_float_t x)
17193 {
17194 // NaN / inf
17195 if (!std::isfinite(x))
17196 {
17197 o->write_characters("null", 4);
17198 return;
17199 }
17200
17201 // If number_float_t is an IEEE-754 single or double precision number,
17202 // use the Grisu2 algorithm to produce short numbers which are
17203 // guaranteed to round-trip, using strtof and strtod, resp.
17204 //
17205 // NB: The test below works if <long double> == <double>.
17206 static constexpr bool is_ieee_single_or_double
17207 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
17208 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
17209
17210 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
17211 }
17212
17213 void dump_float(number_float_t x, std::true_type /*is_ieee_single_or_double*/)
17214 {

Callers 1

dumpMethod · 0.70

Calls 7

removeFunction · 0.85
fillFunction · 0.85
findFunction · 0.70
dataMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected