-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from cppalliance/114
Fix `from_chars` handling of non-finite 80 and 128-bit values
- Loading branch information
Showing
6 changed files
with
329 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2024 Matt Borland | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// https://www.boost.org/LICENSE_1_0.txt | ||
|
||
#ifndef BOOST_GENERATE_NAN_HPP | ||
#define BOOST_GENERATE_NAN_HPP | ||
|
||
#include <cstdint> | ||
#include <cstring> | ||
|
||
#ifdef BOOST_CHARCONV_HAS_FLOAT128 | ||
|
||
namespace boost { | ||
namespace charconv { | ||
namespace detail { | ||
|
||
struct words | ||
{ | ||
#if BOOST_CHARCONV_ENDIAN_LITTLE_BYTE | ||
std::uint64_t lo; | ||
std::uint64_t hi; | ||
#else | ||
std::uint64_t hi; | ||
std::uint64_t lo; | ||
#endif | ||
}; | ||
|
||
inline __float128 nans BOOST_PREVENT_MACRO_SUBSTITUTION () noexcept | ||
{ | ||
words bits; | ||
bits.hi = UINT64_C(0x7FFF400000000000); | ||
bits.lo = UINT64_C(0); | ||
|
||
__float128 return_val; | ||
std::memcpy(&return_val, &bits, sizeof(__float128)); | ||
return return_val; | ||
} | ||
|
||
inline __float128 nanq BOOST_PREVENT_MACRO_SUBSTITUTION () noexcept | ||
{ | ||
words bits; | ||
bits.hi = UINT64_C(0x7FFF800000000000); | ||
bits.lo = UINT64_C(0); | ||
|
||
__float128 return_val; | ||
std::memcpy(&return_val, &bits, sizeof(__float128)); | ||
return return_val; | ||
} | ||
|
||
} //namespace detail | ||
} //namespace charconv | ||
} //namespace boost | ||
|
||
#endif | ||
|
||
#endif //BOOST_GENERATE_NAN_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.