mirror of
https://github.com/boostorg/charconv.git
synced 2026-02-02 20:52:14 +00:00
@@ -57,7 +57,7 @@ from_chars_result from_chars(const char* first, const char* last, Real& value, c
|
||||
* On std::errc::result_out_of_range we return ±0 for small values (e.g. 1.0e-99999) or ±HUGE_VAL for large values (e.g. 1.0e+99999) to match the handling of `std::strtod`.
|
||||
This is a divergence from the standard which states we should return the `value` argument unmodified.
|
||||
* These functions have been tested to support all built-in floating-point types and those from C++23's `<stdfloat>`
|
||||
** Long doubles can be either 64, 80, or 128-bit, but must be IEEE 754 compliant. An example of a non-compliant, and therefore unsupported format is `ibm128`.
|
||||
** Long doubles can be either 64, 80, or 128-bit, but must be IEEE 754 compliant. An example of a non-compliant, and therefore unsupported format is `__ibm128`.
|
||||
** Use of `__float128` or `std::float128_t` requires compiling with `-std=gnu++xx` and linking GCC's `libquadmath`.
|
||||
|
||||
== Examples
|
||||
|
||||
@@ -355,7 +355,7 @@ to_chars_result to_chars_hex(char* first, char* last, Real value, int precision)
|
||||
*first++ = '-';
|
||||
}
|
||||
|
||||
// Print the leading hexit and then mask away
|
||||
// Print the integral part
|
||||
const auto leading_nibble = static_cast<std::uint32_t>(aligned_significand >> hex_bits);
|
||||
*first++ = static_cast<char>('0' + leading_nibble);
|
||||
aligned_significand &= hex_mask;
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
# // Copyright 2020-2023 Daniel Lemire
|
||||
# // Copyright 2023 Matt Borland
|
||||
# // Distributed under the Boost Software License, Version 1.0.
|
||||
# // https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
def format_hex(number):
|
||||
upper = number // (1 << 128)
|
||||
lower = number % (1 << 128)
|
||||
big_upper = upper // (1 << 64)
|
||||
big_lower = upper % (1 << 64)
|
||||
little_upper = lower // (1 << 64)
|
||||
little_lower = lower % (1 << 64)
|
||||
print("{"+hex(big_upper)+","+hex(big_lower)+"},{"+hex(little_upper)+","+hex(little_lower)+"},")
|
||||
|
||||
|
||||
for q in range(-4951, 0):
|
||||
power5 = 5 ** -q
|
||||
z = 0
|
||||
while (1 << z) < power5:
|
||||
z += 1
|
||||
if q >= -55:
|
||||
b = z + 255
|
||||
c = 2 ** b // power5 + 1
|
||||
format_hex(c)
|
||||
else:
|
||||
b = 2 * z + 2 * 128
|
||||
c = 2 ** b // power5 + 1
|
||||
# truncate
|
||||
while c >= (1 << 256):
|
||||
c //= 2
|
||||
format_hex(c)
|
||||
|
||||
|
||||
for q in range(0, 4931 + 1):
|
||||
power5 = 5 ** q
|
||||
# move the most significant bit in position
|
||||
while power5 < (1 << 255):
|
||||
power5 *= 2
|
||||
# *truncate*
|
||||
while power5 >= (1 << 256):
|
||||
power5 //= 2
|
||||
format_hex(power5)
|
||||
Reference in New Issue
Block a user