implements the Grisu2 algorithm for binary to decimal floating-point conversion. More...
Detailed Descriptionimplements the Grisu2 algorithm for binary to decimal floating-point conversion. This implementation is a slightly modified version of the reference implementation which may be obtained from http://florian.loitsch.com/publications (bench.tar.gz). The code is distributed under the MIT license, Copyright (c) 2009 Florian Loitsch. For a detailed description of the algorithm see: [1] Loitsch, "Printing Floating-Point Numbers Quickly and Accurately with Integers", Proceedings of the ACM SIGPLAN 2010 Conference on Programming Language Design and Implementation, PLDI 2010 [2] Burger, Dybvig, "Printing Floating-Point Numbers Quickly and Accurately", Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language Design and Implementation, PLDI 1996 Function Documentation◆ append_exponent()
appends a decimal representation of e to buf
Definition at line 17835 of file json.hpp. References JSON_ASSERT. Referenced by format_buffer(). ◆ compute_boundaries()
template<typename FloatType >
Compute the (normalized) diyfp representing the input number 'value' and its boundaries.
Definition at line 17096 of file json.hpp. References compute_boundaries(), nlohmann::json_abi_v3_11_3::detail::dtoa_impl::diyfp::e, nlohmann::json_abi_v3_11_3::detail::dtoa_impl::diyfp::f, JSON_ASSERT, and nlohmann::json_abi_v3_11_3::detail::value. Referenced by compute_boundaries(), and grisu2(). ◆ find_largest_pow10()
For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k. For n == 0, returns 1 and sets pow10 := 1. Definition at line 17399 of file json.hpp. References find_largest_pow10(). Referenced by find_largest_pow10(), and grisu2_digit_gen(). ◆ format_buffer()
prettify v = buf * 10^decimal_exponent If v is in the range [10^min_exp, 10^max_exp) it will be printed in fixed-point notation. Otherwise it will be printed in exponential notation.
Definition at line 17887 of file json.hpp. References append_exponent(), and JSON_ASSERT. ◆ get_cached_power_for_binary_exponent()
For a normalized diyfp w = f * 2^e, this function returns a (normalized) cached power-of-ten c = f_c * 2^e_c, such that the exponent of the product w * c satisfies (Definition 3.2 from [1]) alpha <= e_c + e + q <= gamma. Definition at line 17235 of file json.hpp. References nlohmann::json_abi_v3_11_3::detail::dtoa_impl::cached_power::e, get_cached_power_for_binary_exponent(), JSON_ASSERT, kAlpha, and kGamma. Referenced by get_cached_power_for_binary_exponent(), and grisu2(). ◆ grisu2() [1/2]
v = buf * 10^decimal_exponent len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. Definition at line 17735 of file json.hpp. References nlohmann::json_abi_v3_11_3::detail::dtoa_impl::diyfp::e, nlohmann::json_abi_v3_11_3::detail::dtoa_impl::cached_power::e, nlohmann::json_abi_v3_11_3::detail::dtoa_impl::diyfp::f, nlohmann::json_abi_v3_11_3::detail::dtoa_impl::cached_power::f, get_cached_power_for_binary_exponent(), grisu2_digit_gen(), JSON_ASSERT, and nlohmann::json_abi_v3_11_3::detail::dtoa_impl::cached_power::k. Referenced by grisu2(). ◆ grisu2() [2/2]
template<typename FloatType >
v = buf * 10^decimal_exponent len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. Definition at line 17795 of file json.hpp. References compute_boundaries(), grisu2(), JSON_ASSERT, nlohmann::json_abi_v3_11_3::detail::dtoa_impl::boundaries::minus, nlohmann::json_abi_v3_11_3::detail::dtoa_impl::boundaries::plus, nlohmann::json_abi_v3_11_3::detail::value, and nlohmann::json_abi_v3_11_3::detail::dtoa_impl::boundaries::w. ◆ grisu2_digit_gen()
Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+. M- and M+ must be normalized and share the same exponent -60 <= e <= -32. Definition at line 17494 of file json.hpp. References nlohmann::json_abi_v3_11_3::detail::dtoa_impl::diyfp::e, nlohmann::json_abi_v3_11_3::detail::dtoa_impl::diyfp::f, find_largest_pow10(), grisu2_digit_gen(), grisu2_round(), JSON_ASSERT, kAlpha, and kGamma. Referenced by grisu2(), and grisu2_digit_gen(). ◆ grisu2_round()
Definition at line 17453 of file json.hpp. References grisu2_round(), and JSON_ASSERT. Referenced by grisu2_digit_gen(), and grisu2_round(). ◆ reinterpret_bits()
template<typename Target , typename Source >
Definition at line 16955 of file json.hpp. References reinterpret_bits(). Referenced by reinterpret_bits(). Variable Documentation◆ kAlpha
Definition at line 17218 of file json.hpp. Referenced by get_cached_power_for_binary_exponent(), and grisu2_digit_gen(). ◆ kGamma
Definition at line 17219 of file json.hpp. Referenced by get_cached_power_for_binary_exponent(), and grisu2_digit_gen(). Generated on Sun Apr 6 2025 11:10:38 for FlexibleSUSY by |