MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / dump_float

Function dump_float

include/behaviortree_cpp/contrib/json.hpp:18807–18826  ·  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

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

Callers 1

dumpMethod · 0.85

Calls 5

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

Tested by

no test coverage detected