DAW JSON Link
Classes | Namespaces | Macros | Functions | Variables
fast_double_parser.h File Reference
#include "../daw_json_exception.h"
#include <daw/daw_bit_cast.h>
#include <daw/daw_cxmath.h>
#include <cfloat>
#include <cinttypes>
#include <ciso646>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>

Go to the source code of this file.

Classes

struct  daw::json::DAW_JSON_VER::fast_double_parser::value128
 

Namespaces

 daw
 
 daw::json
 
 daw::json::DAW_JSON_VER
 
 daw::json::DAW_JSON_VER::fast_double_parser
 
 daw::json::DAW_JSON_VER::fast_double_parser::math_const
 

Macros

#define FASTFLOAT_SMALLEST_POWER   -325
 

Functions

template<typename ExecTag >
constexpr double daw::json::DAW_JSON_VER::fast_double_parser::compute_float_64 (ExecTag exec_tag, std::int64_t power, std::uint64_t whole, double sign)
 
constexpr DAW_ATTRIBUTE_FLATTEN std::uint64_t daw::json::DAW_JSON_VER::fast_double_parser::Emulate64x64to128 (std::uint64_t &r_hi, std::uint64_t const x, std::uint64_t const y)
 
constexpr DAW_ATTRIBUTE_FLATTEN value128 daw::json::DAW_JSON_VER::fast_double_parser::full_multiplication (constexpr_exec_tag const &, std::uint64_t value1, std::uint64_t value2)
 
constexpr DAW_ATTRIBUTE_FLATTEN int daw::json::DAW_JSON_VER::fast_double_parser::leading_zeroes (constexpr_exec_tag const &, std::uint64_t input_num)
 

Variables

constexpr std::uint64_t daw::json::DAW_JSON_VER::fast_double_parser::math_const::mantissa_128 []
 
constexpr std::uint64_t daw::json::DAW_JSON_VER::fast_double_parser::math_const::mantissa_64 []
 
constexpr double daw::json::DAW_JSON_VER::fast_double_parser::math_const::power_of_ten []
 

Macro Definition Documentation

◆ FASTFLOAT_SMALLEST_POWER

#define FASTFLOAT_SMALLEST_POWER   -325

The smallest non-zero float (binary64) is 2^−1074. We take as input numbers of the form w x 10^q where w < 2^64. We have that w * 10^-343 < 2^(64-344) 5^-343 < 2^-1076. However, we have that (2^64-1) * 10^-342 = (2^64-1) * 2^-342 * 5^-342 > 2^−1074. Thus it is possible for a number of the form w * 10^-342 where w is a 64-bit value to be a non-zero floating-point number.

If we are solely interested in the normal numbers then the smallest value is 2^-1022. We can generate a value larger than 2^-1022 with expressions of the form w * 10^-326. Thus we need to pick FASTFLOAT_SMALLEST_POWER >= -326.

Any number of form w * 10^309 where w>= 1 is going to be infinite in binary64 so we never need to worry about powers of 5 greater than 308.