mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-03 19:22:27 +00:00
Release Cosmopolitan v3.6.0
This release is an atomic upgrade to GCC 14.1.0 with C23 and C++23
This commit is contained in:
parent
62ace3623a
commit
5660ec4741
1585 changed files with 117353 additions and 271644 deletions
22
third_party/libcxx/__random/clamp_to_integral.h
vendored
22
third_party/libcxx/__random/clamp_to_integral.h
vendored
|
@ -22,17 +22,18 @@ _LIBCPP_PUSH_MACROS
|
|||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _IntT, class _FloatT,
|
||||
bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
|
||||
int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT {
|
||||
template <class _IntT,
|
||||
class _FloatT,
|
||||
bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
|
||||
int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT {
|
||||
static_assert(is_floating_point<_FloatT>::value, "must be a floating point type");
|
||||
static_assert(is_integral<_IntT>::value, "must be an integral type");
|
||||
static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
|
||||
static_assert((_IsSame<_FloatT, float>::value || _IsSame<_FloatT, double>::value
|
||||
|| _IsSame<_FloatT,long double>::value), "unsupported floating point type");
|
||||
return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits);
|
||||
static_assert(
|
||||
(_IsSame<_FloatT, float>::value || _IsSame<_FloatT, double>::value || _IsSame<_FloatT, long double>::value),
|
||||
"unsupported floating point type");
|
||||
return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits);
|
||||
}
|
||||
|
||||
// Convert a floating point number to the specified integral type after
|
||||
|
@ -40,9 +41,8 @@ _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT {
|
|||
//
|
||||
// The behavior is undefined if `__r` is NaN.
|
||||
template <class _IntT, class _RealT>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_IntT __clamp_to_integral(_RealT __r) _NOEXCEPT {
|
||||
using _Lim = numeric_limits<_IntT>;
|
||||
_LIBCPP_HIDE_FROM_ABI _IntT __clamp_to_integral(_RealT __r) _NOEXCEPT {
|
||||
using _Lim = numeric_limits<_IntT>;
|
||||
const _IntT __max_val = __max_representable_int_for_float<_IntT, _RealT>();
|
||||
if (__r >= ::nextafter(static_cast<_RealT>(__max_val), INFINITY)) {
|
||||
return _Lim::max();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue