-
Notifications
You must be signed in to change notification settings - Fork 167
Closed
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
Just FYI, in GCC we've added support for from_chars for the C++23 std::{,b}float16_t support in https://gcc.gnu.org/r13-3592 .
We've done it by using an artificial wrapper class for each of those and by using float as container type on the library boundary so that
we don't need to change library ABI whenever some new architecture decides to start supporting those formats.
But if you'd want to have direct support for these types in upstream, it could be a matter of:
#if defined(__STDCPP_FLOAT16_T__) || defined(__STDCPP_BFLOAT16_T__)
#include <stdatomic>
#endif
...
#ifdef __STDCPP_FLOAT16_T__
template<>
constexpr int
binary_format<std::float16_t>::mantissa_explicit_bits()
{ return 10; }
template<>
constexpr int
binary_format<std::float16_t>::max_exponent_round_to_even()
{ return 5; }
template<>
constexpr int
binary_format<std::float16_t>::min_exponent_round_to_even()
{ return -22; }
template<>
constexpr int
binary_format<std::float16_t>::minimum_exponent()
{ return -15; }
template<>
constexpr int
binary_format<std::float16_t>::infinite_power()
{ return 0x1F; }
template<>
constexpr int
binary_format<std::float16_t>::sign_index()
{ return 15; }
template<>
constexpr int
binary_format<std::float16_t>::largest_power_of_ten()
{ return 4; }
template<>
constexpr int
binary_format<std::float16_t>::smallest_power_of_ten()
{ return -27; }
template<>
constexpr size_t
binary_format<std::float16_t>::max_digits()
{ return 22; }
#endif
#ifdef __STDCPP_BFLOAT16_T__
template<>
constexpr int
binary_format<std::bfloat16_t>::mantissa_explicit_bits()
{ return 7; }
template<>
constexpr int
binary_format<std::bfloat16_t>::max_exponent_round_to_even()
{ return 3; }
template<>
constexpr int
binary_format<std::bfloat16_t>::min_exponent_round_to_even()
{ return -24; }
template<>
constexpr int
binary_format<std::bfloat16_t>::minimum_exponent()
{ return -127; }
template<>
constexpr int
binary_format<std::bfloat16_t>::infinite_power()
{ return 0xFF; }
template<>
constexpr int
binary_format<std::bfloat16_t>::sign_index()
{ return 15; }
template<>
constexpr int
binary_format<std::bfloat16_t>::largest_power_of_ten()
{ return 38; }
template<>
constexpr int
binary_format<std::bfloat16_t>::smallest_power_of_ten()
{ return -60; }
template<>
constexpr size_t
binary_format<std::bfloat16_t>::max_digits()
{ return 98; }
#endif
And add specializations for {min,max}_exponent_fast_path, max_mantissa_fast_path and exact_power_of_ten (those we didn't need for GCC because we've omitted for these the Clinger's fast path).
lemire and biojppm
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed