⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 limits

📁 C语言库函数的原型,有用的拿去
💻
📖 第 1 页 / 共 3 页
字号:
// limits standard header
#pragma once
#ifndef _LIMITS_
#define _LIMITS_
#ifndef RC_INVOKED
#include <ymath.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cwchar>
#include <xstddef>

 #pragma pack(push,_CRT_PACKING)
 #pragma warning(push,3)

_STD_BEGIN
//	ASSUMES:
//	wraparound 2's complement integer arithmetic w/o traps
//	all CHAR_BITs of each byte used by integers
//	IEC559 (IEEE 754) floating-point arithmetic
//	floating-point errors can trap
//	tinyness detected before floating-point rounding
//	64-bit long long (if _LONGLONG defined)

#undef _STCONS

 #define _STCONS(ty, name, val)	static const ty name = (ty)(val)

		// ENUM float_denorm_style
typedef enum
	{	// constants for different IEEE float denormalization styles
	denorm_indeterminate = -1,
	denorm_absent = 0,
	denorm_present = 1}
		float_denorm_style;

		// ENUM float_round_style
typedef enum
	{	// constants for different IEEE rounding styles
	round_indeterminate = -1,
	round_toward_zero = 0,
	round_to_nearest = 1,
	round_toward_infinity = 2,
	round_toward_neg_infinity = 3}
		float_round_style;

		// STRUCT _Num_base
struct _CRTIMP2_PURE _Num_base
	{	// base for all types, with common defaults
	_STCONS(float_denorm_style, has_denorm, denorm_absent);
	_STCONS(bool, has_denorm_loss, false);
	_STCONS(bool, has_infinity, false);
	_STCONS(bool, has_quiet_NaN, false);
	_STCONS(bool, has_signaling_NaN, false);
	_STCONS(bool, is_bounded, false);
	_STCONS(bool, is_exact, false);
	_STCONS(bool, is_iec559, false);
	_STCONS(bool, is_integer, false);
	_STCONS(bool, is_modulo, false);
	_STCONS(bool, is_signed, false);
	_STCONS(bool, is_specialized, false);
	_STCONS(bool, tinyness_before, false);
	_STCONS(bool, traps, false);
	_STCONS(float_round_style, round_style, round_toward_zero);
	_STCONS(int, digits, 0);
	_STCONS(int, digits10, 0);

 #if _HAS_CPP0X
	_STCONS(int, max_digits10, 0);
 #endif /* _HAS_CPP0X */

	_STCONS(int, max_exponent, 0);
	_STCONS(int, max_exponent10, 0);
	_STCONS(int, min_exponent, 0);
	_STCONS(int, min_exponent10, 0);
	_STCONS(int, radix, 0);
	};

		// TEMPLATE CLASS numeric_limits
template<class _Ty>
	class numeric_limits
		: public _Num_base
	{	// numeric limits for arbitrary type _Ty (say little or nothing)
public:
	static _Ty (__CRTDECL min)() _THROW0()
		{	// return minimum value
		return (_Ty(0));
		}

	static _Ty (__CRTDECL max)() _THROW0()
		{	// return maximum value
		return (_Ty(0));
		}

 #if _HAS_CPP0X
	static _Ty __CRTDECL lowest() _THROW0()
		{	// return most negative value
		return ((min)());
		}
 #endif /* _HAS_CPP0X */

	static _Ty __CRTDECL epsilon() _THROW0()
		{	// return smallest effective increment from 1.0
		return (_Ty(0));
		}

	static _Ty __CRTDECL round_error() _THROW0()
		{	// return largest rounding error
		return (_Ty(0));
		}

	static _Ty __CRTDECL denorm_min() _THROW0()
		{	// return minimum denormalized value
		return (_Ty(0));
		}

	static _Ty __CRTDECL infinity() _THROW0()
		{	// return positive infinity
		return (_Ty(0));
		}

	static _Ty __CRTDECL quiet_NaN() _THROW0()
		{	// return non-signaling NaN
		return (_Ty(0));
		}

	static _Ty __CRTDECL signaling_NaN() _THROW0()
		{	// return signaling NaN
		return (_Ty(0));
		}
	};

template<class _Ty>
	class numeric_limits<const _Ty>
		: public numeric_limits<_Ty>
	{	// numeric limits for const types
	};

template<class _Ty>
	class numeric_limits<volatile _Ty>
		: public numeric_limits<_Ty>
	{	// numeric limits for volatile types
	};

template<class _Ty>
	class numeric_limits<const volatile _Ty>
		: public numeric_limits<_Ty>
	{	// numeric limits for const volatile types
	};

		// STRUCT _Num_int_base
struct _CRTIMP2_PURE _Num_int_base
	: public _Num_base
	{	// base for integer types
	_STCONS(bool, is_bounded, true);
	_STCONS(bool, is_exact, true);
	_STCONS(bool, is_integer, true);
	_STCONS(bool, is_modulo, true);
	_STCONS(bool, is_specialized, true);
	_STCONS(int, radix, 2);
	};

		// STRUCT _Num_float_base
struct _CRTIMP2_PURE _Num_float_base
	: public _Num_base
	{	// base for floating-point types
	_STCONS(float_denorm_style, has_denorm, denorm_present);
	_STCONS(bool, has_denorm_loss, true);
	_STCONS(bool, has_infinity, true);
	_STCONS(bool, has_quiet_NaN, true);
	_STCONS(bool, has_signaling_NaN, true);
	_STCONS(bool, is_bounded, true);
	_STCONS(bool, is_exact, false);
	_STCONS(bool, is_iec559, true);
	_STCONS(bool, is_integer, false);
	_STCONS(bool, is_modulo, false);
	_STCONS(bool, is_signed, true);
	_STCONS(bool, is_specialized, true);
	_STCONS(bool, tinyness_before, true);
	_STCONS(bool, traps, true);
	_STCONS(float_round_style, round_style, round_to_nearest);
	_STCONS(int, radix, FLT_RADIX);
	};

		// CLASS numeric_limits<char>
template<> class _CRTIMP2_PURE numeric_limits<char>
	: public _Num_int_base
	{	// limits for type char
public:
	typedef char _Ty;

	static _Ty (__CRTDECL min)() _THROW0()
		{	// return minimum value
		return (CHAR_MIN);
		}

	static _Ty (__CRTDECL max)() _THROW0()
		{	// return maximum value
		return (CHAR_MAX);
		}

 #if _HAS_CPP0X
	static _Ty __CRTDECL lowest() _THROW0()
		{	// return most negative value
		return ((min)());
		}
 #endif /* _HAS_CPP0X */

	static _Ty __CRTDECL epsilon() _THROW0()
		{	// return smallest effective increment from 1.0
		return (0);
		}

	static _Ty __CRTDECL round_error() _THROW0()
		{	// return largest rounding error
		return (0);
		}

	static _Ty __CRTDECL denorm_min() _THROW0()
		{	// return minimum denormalized value
		return (0);
		}

	static _Ty __CRTDECL infinity() _THROW0()
		{	// return positive infinity
		return (0);
		}

	static _Ty __CRTDECL quiet_NaN() _THROW0()
		{	// return non-signaling NaN
		return (0);
		}

	static _Ty __CRTDECL signaling_NaN() _THROW0()
		{	// return signaling NaN
		return (0);
		}

	_STCONS(bool, is_signed, CHAR_MIN != 0);
	_STCONS(int, digits, CHAR_BIT - (CHAR_MIN != 0 ? 1 : 0));
	_STCONS(int, digits10, (CHAR_BIT - (CHAR_MIN != 0 ? 1 : 0))
		* 301L / 1000);

 #if _HAS_CPP0X
	_STCONS(int, max_digits10, 2 + (CHAR_BIT - (CHAR_MIN != 0 ? 1 : 0))
		* 301L / 1000);
 #endif /* _HAS_CPP0X */
	};

		// CLASS numeric_limits<wchar_t>
template<> class _CRTIMP2_PURE numeric_limits<wchar_t>
	: public _Num_int_base
	{	// limits for type wchar_t
public:
	typedef wchar_t _Ty;

	static _Ty (__CRTDECL min)() _THROW0()
		{	// return minimum value
		return ((_Ty)WCHAR_MIN);
		}

	static _Ty (__CRTDECL max)() _THROW0()
		{	// return maximum value
		return ((_Ty)WCHAR_MAX);
		}

 #if _HAS_CPP0X
	static _Ty __CRTDECL lowest() _THROW0()
		{	// return most negative value
		return ((min)());
		}
 #endif /* _HAS_CPP0X */

	static _Ty __CRTDECL epsilon() _THROW0()
		{	// return smallest effective increment from 1.0
		return (0);
		}

	static _Ty __CRTDECL round_error() _THROW0()
		{	// return largest rounding error
		return (0);
		}

	static _Ty __CRTDECL denorm_min() _THROW0()
		{	// return minimum denormalized value
		return (0);
		}

	static _Ty __CRTDECL infinity() _THROW0()
		{	// return positive infinity
		return (0);
		}

	static _Ty __CRTDECL quiet_NaN() _THROW0()
		{	// return non-signaling NaN
		return (0);
		}

	static _Ty __CRTDECL signaling_NaN() _THROW0()
		{	// return signaling NaN
		return (0);
		}

	_STCONS(bool, is_signed, WCHAR_MIN != 0);
	_STCONS(int, digits, CHAR_BIT * sizeof (wchar_t)
		- (WCHAR_MIN != 0 ? 1 : 0));
	_STCONS(int, digits10, (CHAR_BIT * sizeof (wchar_t)
		- (WCHAR_MIN != 0 ? 1 : 0)) * 301L / 1000);

 #if _HAS_CPP0X
	_STCONS(int, max_digits10, 2 + (CHAR_BIT * sizeof (wchar_t)
		- (WCHAR_MIN != 0 ? 1 : 0)) * 301L / 1000);
 #endif /* _HAS_CPP0X */
	};

		// CLASS numeric_limits<_Bool>
template<> class _CRTIMP2_PURE numeric_limits<_Bool>
	: public _Num_int_base
	{	// limits for type bool
public:
	typedef bool _Ty;

	static _Ty (__CRTDECL min)() _THROW0()
		{	// return minimum value
		return (false);
		}

	static _Ty (__CRTDECL max)() _THROW0()
		{	// return maximum value
		return (true);
		}

 #if _HAS_CPP0X
	static _Ty __CRTDECL lowest() _THROW0()
		{	// return most negative value
		return ((min)());
		}
 #endif /* _HAS_CPP0X */

	static _Ty __CRTDECL epsilon() _THROW0()
		{	// return smallest effective increment from 1.0
		return (0);
		}

	static _Ty __CRTDECL round_error() _THROW0()
		{	// return largest rounding error
		return (0);
		}

	static _Ty __CRTDECL denorm_min() _THROW0()
		{	// return minimum denormalized value
		return (0);
		}

	static _Ty __CRTDECL infinity() _THROW0()
		{	// return positive infinity
		return (0);
		}

	static _Ty __CRTDECL quiet_NaN() _THROW0()
		{	// return non-signaling NaN
		return (0);
		}

	static _Ty __CRTDECL signaling_NaN() _THROW0()
		{	// return signaling NaN
		return (0);
		}

	_STCONS(bool, is_modulo, false);
	_STCONS(bool, is_signed, false);
	_STCONS(int, digits, 1);
	_STCONS(int, digits10, 0);

 #if _HAS_CPP0X
	_STCONS(int, max_digits10, 0);
 #endif /* _HAS_CPP0X */
	};

		// CLASS numeric_limits<signed char>
template<> class _CRTIMP2_PURE numeric_limits<signed char>
	: public _Num_int_base
	{	// limits for type signed char
public:
	typedef signed char _Ty;

	static _Ty (__CRTDECL min)() _THROW0()
		{	// return minimum value
		return (SCHAR_MIN);
		}

	static _Ty (__CRTDECL max)() _THROW0()
		{	// return maximum value
		return (SCHAR_MAX);
		}

 #if _HAS_CPP0X
	static _Ty __CRTDECL lowest() _THROW0()
		{	// return most negative value
		return ((min)());
		}
 #endif /* _HAS_CPP0X */

	static _Ty __CRTDECL epsilon() _THROW0()
		{	// return smallest effective increment from 1.0
		return (0);
		}

	static _Ty __CRTDECL round_error() _THROW0()
		{	// return largest rounding error
		return (0);
		}

	static _Ty __CRTDECL denorm_min() _THROW0()
		{	// return minimum denormalized value
		return (0);
		}

	static _Ty __CRTDECL infinity() _THROW0()
		{	// return positive infinity
		return (0);
		}

	static _Ty __CRTDECL quiet_NaN() _THROW0()
		{	// return non-signaling NaN
		return (0);
		}

	static _Ty __CRTDECL signaling_NaN() _THROW0()
		{	// return signaling NaN
		return (0);
		}

	_STCONS(bool, is_signed, true);
	_STCONS(int, digits, CHAR_BIT - 1);
	_STCONS(int, digits10, (CHAR_BIT - 1) * 301L / 1000);

 #if _HAS_CPP0X
	_STCONS(int, max_digits10, 2 + (CHAR_BIT - 1) * 301L / 1000);
 #endif /* _HAS_CPP0X */
	};

		// CLASS numeric_limits<unsigned char>
template<> class _CRTIMP2_PURE numeric_limits<unsigned char>
	: public _Num_int_base
	{	// limits for type unsigned char
public:
	typedef unsigned char _Ty;

	static _Ty (__CRTDECL min)() _THROW0()
		{	// return minimum value
		return (0);
		}

	static _Ty (__CRTDECL max)() _THROW0()
		{	// return maximum value
		return (UCHAR_MAX);
		}

 #if _HAS_CPP0X
	static _Ty __CRTDECL lowest() _THROW0()
		{	// return most negative value
		return ((min)());
		}
 #endif /* _HAS_CPP0X */

	static _Ty __CRTDECL epsilon() _THROW0()
		{	// return smallest effective increment from 1.0
		return (0);
		}

	static _Ty __CRTDECL round_error() _THROW0()
		{	// return largest rounding error
		return (0);
		}

	static _Ty __CRTDECL denorm_min() _THROW0()
		{	// return minimum denormalized value
		return (0);
		}

	static _Ty __CRTDECL infinity() _THROW0()
		{	// return positive infinity
		return (0);
		}

	static _Ty __CRTDECL quiet_NaN() _THROW0()
		{	// return non-signaling NaN
		return (0);
		}

	static _Ty __CRTDECL signaling_NaN() _THROW0()
		{	// return signaling NaN
		return (0);
		}

	_STCONS(bool, is_signed, false);
	_STCONS(int, digits, CHAR_BIT);
	_STCONS(int, digits10, CHAR_BIT * 301L / 1000);

 #if _HAS_CPP0X
	_STCONS(int, max_digits10, 2 + (CHAR_BIT) * 301L / 1000);
 #endif /* _HAS_CPP0X */
	};

		// CLASS numeric_limits<short>
template<> class _CRTIMP2_PURE numeric_limits<short>
	: public _Num_int_base
	{	// limits for type short
public:
	typedef short _Ty;

	static _Ty (__CRTDECL min)() _THROW0()
		{	// return minimum value
		return (SHRT_MIN);
		}

	static _Ty (__CRTDECL max)() _THROW0()
		{	// return maximum value
		return (SHRT_MAX);
		}

 #if _HAS_CPP0X
	static _Ty __CRTDECL lowest() _THROW0()
		{	// return most negative value
		return ((min)());
		}
 #endif /* _HAS_CPP0X */

	static _Ty __CRTDECL epsilon() _THROW0()
		{	// return smallest effective increment from 1.0
		return (0);
		}

	static _Ty __CRTDECL round_error() _THROW0()
		{	// return largest rounding error
		return (0);
		}

	static _Ty __CRTDECL denorm_min() _THROW0()
		{	// return minimum denormalized value
		return (0);
		}

	static _Ty __CRTDECL infinity() _THROW0()
		{	// return positive infinity
		return (0);
		}

	static _Ty __CRTDECL quiet_NaN() _THROW0()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -