MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / dump_float

Function dump_float

extern/json/json.hpp:18721–18740  ·  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

18719 @param[in] x floating-point number to dump
18720 */
18721 void dump_float(number_float_t x)
18722 {
18723 // NaN / inf
18724 if (!std::isfinite(x))
18725 {
18726 o->write_characters("null", 4);
18727 return;
18728 }
18729
18730 // If number_float_t is an IEEE-754 single or double precision number,
18731 // use the Grisu2 algorithm to produce short numbers which are
18732 // guaranteed to round-trip, using strtof and strtod, resp.
18733 //
18734 // NB: The test below works if <long double> == <double>.
18735 static constexpr bool is_ieee_single_or_double
18736 = (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) ||
18737 (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);
18738
18739 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
18740 }
18741
18742 void dump_float(number_float_t x, std::true_type /*is_ieee_single_or_double*/)
18743 {

Callers 1

dumpMethod · 0.85

Calls 6

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

Tested by

no test coverage detected