mirror of
https://github.com/boostorg/math.git
synced 2026-01-29 07:42:11 +00:00
385 lines
18 KiB
C++
385 lines
18 KiB
C++
///////////////////////////////////////////////////////////////////////////////
|
|
// Copyright Christopher Kormanyos 2014.
|
|
// Copyright John Maddock 2014.
|
|
// Copyright Paul Bristow 2014.
|
|
// Distributed under the Boost Software License,
|
|
// Version 1.0. (See accompanying file LICENSE_1_0.txt
|
|
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
//
|
|
|
|
// <boost/cstdfloat.hpp> implements floating-point typedefs having
|
|
// specified widths, as described in N3626 (proposed for C++14).
|
|
// See: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3626.pdf
|
|
|
|
#ifndef _BOOST_CSTDFLOAT_2014_01_09_HPP_
|
|
#define _BOOST_CSTDFLOAT_2014_01_09_HPP_
|
|
|
|
#include <float.h>
|
|
#include <limits>
|
|
#include <boost/static_assert.hpp>
|
|
#include <boost/math/tools/config.hpp>
|
|
|
|
// This is the beginning of the preamble.
|
|
|
|
// In this preamble, the preprocessor is used to query certain
|
|
// preprocessor definitions from <float.h>. Based on the results
|
|
// of these queries, an attempt is made to automatically detect
|
|
// the presence of built-in floating-point types having specified
|
|
// widths. These are *thought* to be conformant with IEEE-754,
|
|
// whereby an unequivocal test based on numeric_limits follows below.
|
|
|
|
// In addition, macros that are used for initializing floating-point
|
|
// literal values and some basic min/max values are defined.
|
|
|
|
// First, we will pre-load certain preprocessor definitions
|
|
// with a dummy value.
|
|
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 0
|
|
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE 0
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE 0
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE 0
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 0
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 0
|
|
|
|
// Ensure that the compiler has a radix-2 floating-point representation.
|
|
#if (!defined(FLT_RADIX) || ((defined(FLT_RADIX) && (FLT_RADIX != 2))))
|
|
#error The compiler does not support radix-2 floating-point types required for <boost/cstdfloat.hpp>.
|
|
#endif
|
|
|
|
// Check if built-in float is equivalent to float16_t, float32_t, float64_t, float80_t, or float128_t.
|
|
#if(defined(FLT_MANT_DIG) && defined(FLT_MAX_EXP))
|
|
#if ((FLT_MANT_DIG == 11) && (FLT_MAX_EXP == 16) && (BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT16_NATIVE_TYPE float
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 16
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT16_C(x) (x ## F)
|
|
#define BOOST_FLOAT_16_MIN FLT_MIN
|
|
#define BOOST_FLOAT_16_MAX FLT_MAX
|
|
#elif((FLT_MANT_DIG == 24) && (FLT_MAX_EXP == 128) && (BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT32_NATIVE_TYPE float
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 32
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT32_C(x) (x ## F)
|
|
#define BOOST_FLOAT_32_MIN FLT_MIN
|
|
#define BOOST_FLOAT_32_MAX FLT_MAX
|
|
#elif((FLT_MANT_DIG == 53) && (FLT_MAX_EXP == 1024) && (BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT64_NATIVE_TYPE float
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 64
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT64_C(x) (x ## F)
|
|
#define BOOST_FLOAT_64_MIN FLT_MIN
|
|
#define BOOST_FLOAT_64_MAX FLT_MAX
|
|
#elif((FLT_MANT_DIG == 64) && (FLT_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT80_NATIVE_TYPE float
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 80
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT80_C(x) (x ## F)
|
|
#define BOOST_FLOAT_80_MIN FLT_MIN
|
|
#define BOOST_FLOAT_80_MAX FLT_MAX
|
|
#elif((FLT_MANT_DIG == 113) && (FLT_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE float
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 128
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT128_C(x) (x ## F)
|
|
#define BOOST_FLOAT_128_MIN FLT_MIN
|
|
#define BOOST_FLOAT_128_MAX FLT_MAX
|
|
#endif
|
|
#endif
|
|
|
|
// Check if built-in double is equivalent to float16_t, float32_t, float64_t, float80_t, or float128_t.
|
|
#if(defined(DBL_MANT_DIG) && defined(DBL_MAX_EXP))
|
|
#if ((DBL_MANT_DIG == 11) && (DBL_MAX_EXP == 16) && (BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT16_NATIVE_TYPE double
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 16
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT16_C(x) (x)
|
|
#define BOOST_FLOAT_16_MIN DBL_MIN
|
|
#define BOOST_FLOAT_16_MAX DBL_MAX
|
|
#elif((DBL_MANT_DIG == 24) && (DBL_MAX_EXP == 128) && (BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT32_NATIVE_TYPE double
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 32
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT32_C(x) (x)
|
|
#define BOOST_FLOAT_32_MIN DBL_MIN
|
|
#define BOOST_FLOAT_32_MAX DBL_MAX
|
|
#elif((DBL_MANT_DIG == 53) && (DBL_MAX_EXP == 1024) && (BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT64_NATIVE_TYPE double
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 64
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT64_C(x) (x)
|
|
#define BOOST_FLOAT_64_MIN DBL_MIN
|
|
#define BOOST_FLOAT_64_MAX DBL_MAX
|
|
#elif((DBL_MANT_DIG == 64) && (DBL_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT80_NATIVE_TYPE double
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 80
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT80_C(x) (x)
|
|
#define BOOST_FLOAT_80_MIN DBL_MIN
|
|
#define BOOST_FLOAT_80_MAX DBL_MAX
|
|
#elif((DBL_MANT_DIG == 113) && (DBL_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE double
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 128
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT128_C(x) (x)
|
|
#define BOOST_FLOAT_128_MIN DBL_MIN
|
|
#define BOOST_FLOAT_128_MAX DBL_MAX
|
|
#endif
|
|
#endif
|
|
|
|
// Check if built-in long double is equivalent to float16_t, float32_t, float64_t, float80_t, or float128_t.
|
|
#if(defined(LDBL_MANT_DIG) && defined(LDBL_MAX_EXP))
|
|
#if ((LDBL_MANT_DIG == 11) && (LDBL_MAX_EXP == 16) && (BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT16_NATIVE_TYPE long double
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 16
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT16_C(x) (x ## L)
|
|
#define BOOST_FLOAT_16_MIN LDBL_MIN
|
|
#define BOOST_FLOAT_16_MAX LDBL_MAX
|
|
#elif((LDBL_MANT_DIG == 24) && (LDBL_MAX_EXP == 128) && (BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT32_NATIVE_TYPE long double
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 32
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT32_C(x) (x ## L)
|
|
#define BOOST_FLOAT_32_MIN LDBL_MIN
|
|
#define BOOST_FLOAT_32_MAX LDBL_MAX
|
|
#elif((LDBL_MANT_DIG == 53) && (LDBL_MAX_EXP == 1024) && (BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT64_NATIVE_TYPE long double
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 64
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT64_C(x) (x ## L)
|
|
#define BOOST_FLOAT_64_MIN LDBL_MIN
|
|
#define BOOST_FLOAT_64_MAX LDBL_MAX
|
|
#elif((LDBL_MANT_DIG == 64) && (LDBL_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT80_NATIVE_TYPE long double
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 80
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT80_C(x) (x ## L)
|
|
#define BOOST_FLOAT_80_MIN LDBL_MIN
|
|
#define BOOST_FLOAT_80_MAX LDBL_MAX
|
|
#elif((LDBL_MANT_DIG == 113) && (LDBL_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0))
|
|
#define BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE long double
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 128
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT128_C(x) (x ## L)
|
|
#define BOOST_FLOAT_128_MIN LDBL_MIN
|
|
#define BOOST_FLOAT_128_MAX LDBL_MAX
|
|
#endif
|
|
#endif
|
|
|
|
// Check if __float128 from GCC's libquadmath or if (potentially)
|
|
// ICC's /Qlong-double flag is supported.
|
|
// TODO: Should we allow BOOST_MATH_USE_FLOAT128 for ICC?
|
|
// Here, we use the BOOST_MATH_USE_FLOAT128 pre-processor
|
|
// definition from <boost/math/tools/config.hpp>.
|
|
#if(BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0) && defined(BOOST_MATH_USE_FLOAT128)
|
|
#define BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE __float128
|
|
#undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
|
|
#define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 128
|
|
#undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE
|
|
#define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 1
|
|
#define BOOST_FLOAT128_C(x) (x ## Q)
|
|
#define BOOST_FLOAT_128_MIN FLT128_MIN
|
|
#define BOOST_FLOAT_128_MAX FLT128_MAX
|
|
#endif
|
|
|
|
// This is the end of the preamble. Now we use the results
|
|
// of the queries that have been obtained in the preamble.
|
|
|
|
// Ensure that the compiler has any suitable floating-point type whatsoever.
|
|
#if ( (BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 0) \
|
|
&& (BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 0) \
|
|
&& (BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 0) \
|
|
&& (BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 0) \
|
|
&& (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0))
|
|
#error The compiler does not support any of the floating-point types required for <boost/cstdfloat.hpp>.
|
|
#endif
|
|
|
|
// The following section contains the various min/max macros
|
|
// for the *leastN and *fastN types.
|
|
|
|
#if(BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 1)
|
|
#define BOOST_FLOAT_FAST16_MIN BOOST_FLOAT_16_MIN
|
|
#define BOOST_FLOAT_LEAST16_MIN BOOST_FLOAT_16_MIN
|
|
#define BOOST_FLOAT_FAST16_MAX BOOST_FLOAT_16_MAX
|
|
#define BOOST_FLOAT_LEAST16_MAX BOOST_FLOAT_16_MAX
|
|
#endif
|
|
|
|
#if(BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 1)
|
|
#define BOOST_FLOAT_FAST32_MIN BOOST_FLOAT_32_MIN
|
|
#define BOOST_FLOAT_LEAST32_MIN BOOST_FLOAT_32_MIN
|
|
#define BOOST_FLOAT_FAST32_MAX BOOST_FLOAT_32_MAX
|
|
#define BOOST_FLOAT_LEAST32_MAX BOOST_FLOAT_32_MAX
|
|
#endif
|
|
|
|
#if(BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 1)
|
|
#define BOOST_FLOAT_FAST64_MIN BOOST_FLOAT_64_MIN
|
|
#define BOOST_FLOAT_LEAST64_MIN BOOST_FLOAT_64_MIN
|
|
#define BOOST_FLOAT_FAST64_MAX BOOST_FLOAT_64_MAX
|
|
#define BOOST_FLOAT_LEAST64_MAX BOOST_FLOAT_64_MAX
|
|
#endif
|
|
|
|
#if(BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 1)
|
|
#define BOOST_FLOAT_FAST80_MIN BOOST_FLOAT_80_MIN
|
|
#define BOOST_FLOAT_LEAST80_MIN BOOST_FLOAT_80_MIN
|
|
#define BOOST_FLOAT_FAST80_MAX BOOST_FLOAT_80_MAX
|
|
#define BOOST_FLOAT_LEAST80_MAX BOOST_FLOAT_80_MAX
|
|
#endif
|
|
|
|
#define BOOST_NO_FLOAT128_T
|
|
|
|
#if(BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 1)
|
|
#undef BOOST_NO_FLOAT128_T
|
|
#define BOOST_FLOAT_FAST128_MIN BOOST_FLOAT_128_MIN
|
|
#define BOOST_FLOAT_LEAST128_MIN BOOST_FLOAT_128_MIN
|
|
#define BOOST_FLOAT_FAST128_MAX BOOST_FLOAT_128_MAX
|
|
#define BOOST_FLOAT_LEAST128_MAX BOOST_FLOAT_128_MAX
|
|
#endif
|
|
|
|
// The following section contains the various min/max macros
|
|
// for the *floatmax types.
|
|
|
|
#if (BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 16)
|
|
#define BOOST_FLOATMAX_C(x) BOOST_FLOAT16_C(x)
|
|
#define BOOST_FLOATMAX_MIN BOOST_FLOAT_16_MIN
|
|
#define BOOST_FLOATMAX_MAX BOOST_FLOAT_16_MAX
|
|
#elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 32)
|
|
#define BOOST_FLOATMAX_C(x) BOOST_FLOAT32_C(x)
|
|
#define BOOST_FLOATMAX_MIN BOOST_FLOAT_32_MIN
|
|
#define BOOST_FLOATMAX_MAX BOOST_FLOAT_32_MAX
|
|
#elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 64)
|
|
#define BOOST_FLOATMAX_C(x) BOOST_FLOAT64_C(x)
|
|
#define BOOST_FLOATMAX_MIN BOOST_FLOAT_64_MIN
|
|
#define BOOST_FLOATMAX_MAX BOOST_FLOAT_64_MAX
|
|
#elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 80)
|
|
#define BOOST_FLOATMAX_C(x) BOOST_FLOAT80_C(x)
|
|
#define BOOST_FLOATMAX_MIN BOOST_FLOAT_80_MIN
|
|
#define BOOST_FLOATMAX_MAX BOOST_FLOAT_80_MAX
|
|
#elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 128)
|
|
#define BOOST_FLOATMAX_C(x) BOOST_FLOAT128_C(x)
|
|
#define BOOST_FLOATMAX_MIN BOOST_FLOAT_128_MIN
|
|
#define BOOST_FLOATMAX_MAX BOOST_FLOAT_128_MAX
|
|
#else
|
|
#error The maximum available floating-point width for <boost/cstdfloat.hpp> is undefined.
|
|
#endif
|
|
|
|
// Here, we define the floating-point typedefs having specified widths.
|
|
// The types are defined in the namespace boost.
|
|
|
|
// For simplicity, the least and fast types are type defined identically
|
|
// as the corresponding fixed-width type. This behavior can, however,
|
|
// be modified in order to be optimized for a given compiler implementation.
|
|
|
|
// In addition, a clear assessment of IEEE-754 comformance is carried out
|
|
// using compile-time assertion.
|
|
|
|
namespace boost
|
|
{
|
|
#if(BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 1)
|
|
typedef BOOST_CSTDFLOAT_FLOAT16_NATIVE_TYPE float16_t;
|
|
typedef float16_t float_fast16_t;
|
|
typedef float16_t float_least16_t;
|
|
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float16_t>::is_iec559 == true);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float16_t>::radix == 2);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float16_t>::digits == 11);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float16_t>::max_exponent == 16);
|
|
#endif
|
|
|
|
#if(BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 1)
|
|
typedef BOOST_CSTDFLOAT_FLOAT32_NATIVE_TYPE float32_t;
|
|
typedef float32_t float_fast32_t;
|
|
typedef float32_t float_least32_t;
|
|
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float32_t>::is_iec559 == true);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float32_t>::radix == 2);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float32_t>::digits == 24);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float32_t>::max_exponent == 128);
|
|
#endif
|
|
|
|
#if(BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 1)
|
|
typedef BOOST_CSTDFLOAT_FLOAT64_NATIVE_TYPE float64_t;
|
|
typedef float64_t float_fast64_t;
|
|
typedef float64_t float_least64_t;
|
|
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float64_t>::is_iec559 == true);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float64_t>::radix == 2);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float64_t>::digits == 53);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float64_t>::max_exponent == 1024);
|
|
#endif
|
|
|
|
#if(BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 1)
|
|
typedef BOOST_CSTDFLOAT_FLOAT80_NATIVE_TYPE float80_t;
|
|
typedef float80_t float_fast80_t;
|
|
typedef float80_t float_least80_t;
|
|
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float80_t>::is_iec559 == true);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float80_t>::radix == 2);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float80_t>::digits == 64);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float80_t>::max_exponent == 16384);
|
|
#endif
|
|
|
|
#if(BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 1)
|
|
typedef BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE float128_t;
|
|
typedef float128_t float_fast128_t;
|
|
typedef float128_t float_least128_t;
|
|
|
|
// Here, we decide that it is not sensible to use or to provide (in any way)
|
|
// a specialization of numeric_limits for the compiler-specific type __float128.
|
|
// Users must provide their own mechanism for this.
|
|
#if !defined(BOOST_MATH_USE_FLOAT128)
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float128_t>::is_iec559 == true);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float128_t>::radix == 2);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float128_t>::digits == 113);
|
|
BOOST_STATIC_ASSERT(std::numeric_limits<float128_t>::max_exponent == 16384);
|
|
#endif
|
|
#endif
|
|
|
|
#if (BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 16)
|
|
typedef float16_t floatmax_t;
|
|
#elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 32)
|
|
typedef float32_t floatmax_t;
|
|
#elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 64)
|
|
typedef float64_t floatmax_t;
|
|
#elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 80)
|
|
typedef float80_t floatmax_t;
|
|
#elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 128)
|
|
typedef float128_t floatmax_t;
|
|
#else
|
|
#error The maximum available floating-point width for <boost/cstdfloat.hpp> is undefined.
|
|
#endif
|
|
}
|
|
// namespace boost
|
|
|
|
#endif // _BOOST_CSTDFLOAT_2014_01_09_HPP_
|