MCPcopy Create free account
hub / github.com/LAStools/LAStools / dump_float

Function dump_float

src/json.hpp:18811–18830  ·  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

18809 @param[in] x floating-point number to dump
18810 */
18811 void dump_float(number_float_t x)
18812 {
18813 // NaN / inf
18814 if (!std::isfinite(x))
18815 {
18816 o->write_characters("null", 4);
18817 return;
18818 }
18819
18820 // If number_float_t is an IEEE-754 single or double precision number,
18821 // use the Grisu2 algorithm to produce short numbers which are
18822 // guaranteed to round-trip, using strtof and strtod, resp.
18823 //
18824 // NB: The test below works if <long double> == <double>.
18825 static constexpr bool is_ieee_single_or_double
18826 = (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) ||
18827 (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);
18828
18829 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
18830 }
18831
18832 void dump_float(number_float_t x, std::true_type /*is_ieee_single_or_double*/)
18833 {

Callers 1

dumpMethod · 0.85

Calls 5

findFunction · 0.85
dataMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected