Which member function returns the largest integer value that is equal to or less than a number?

template class numeric_limits;

The numeric_limits class template provides a standardized way to query various properties of arithmetic types [e.g. the largest possible value for type int is std::numeric_limits::max[]].

This information is provided via specializations of the numeric_limits template. The standard library makes available specializations for all arithmetic types:

Defined in header

template class numeric_limits;

template class numeric_limits;

template class numeric_limits;

template class numeric_limits;

template class numeric_limits;

template class numeric_limits;

[since C++20]

template class numeric_limits;

[since C++11]

template class numeric_limits;

[since C++11]

template class numeric_limits;

template class numeric_limits;

template class numeric_limits;

template class numeric_limits;

template class numeric_limits;

template class numeric_limits;

template class numeric_limits;

[since C++11]

template class numeric_limits;

[since C++11]

template class numeric_limits;

template class numeric_limits;

template class numeric_limits;

Additionally, a specialization exists for every cv-qualified version of each cv-unqualified type for which the specialization exists, identical to the unqualified specialization, e.g. std::numeric_limits, std::numeric_limits, and std::numeric_limits are provided and are equivalent to std::numeric_limits.

Aliases of arithmetic types [such as std::size_t or std::streamsize] may also be examined with the std::numeric_limits type traits.

Non-arithmetic standard types, such as std::complex or std::nullptr_t, do not have specializations.

If the implementation defines any integer-class types, specializations of std::numeric_limits must also be provided for them.

[since C++20]

Implementations may provide specializations of std::numeric_limits for implementation-specific types: e.g. GCC provides std::numeric_limits. Non-standard libraries may add specializations for library-provided types, e.g. OpenEXR provides std::numeric_limits for a 16-bit floating-point type.

Contents

  • 1 Template parameters
  • 2 Member constants
  • 3 Member functions
  • 4 Helper classes
  • 5 Relationship with C library macro constants
  • 6 Example
  • 7 See also

[edit] Template parameters

T - a type to retrieve numeric properties for

[edit] Member constants

is_specialized

[static]

identifies types for which std::numeric_limits is specialized
[public static member constant] [edit]

is_signed

[static]

identifies signed types
[public static member constant] [edit]

is_integer

[static]

identifies integer types
[public static member constant] [edit]

is_exact

[static]

identifies exact types
[public static member constant] [edit]

has_infinity

[static]

identifies floating-point types that can represent the special value "positive infinity"
[public static member constant] [edit]

has_quiet_NaN

[static]

identifies floating-point types that can represent the special value "quiet not-a-number" [NaN]
[public static member constant] [edit]

has_signaling_NaN

[static]

identifies floating-point types that can represent the special value "signaling not-a-number" [NaN]
[public static member constant] [edit]

has_denorm

[static]

identifies the denormalization style used by the floating-point type
[public static member constant] [edit]

has_denorm_loss

[static]

identifies the floating-point types that detect loss of precision as denormalization loss rather than inexact result
[public static member constant] [edit]

round_style

[static]

identifies the rounding style used by the type
[public static member constant] [edit]

is_iec559

[static]

identifies the IEC 559/IEEE 754 floating-point types
[public static member constant] [edit]

is_bounded

[static]

identifies types that represent a finite set of values
[public static member constant] [edit]

is_modulo

[static]

identifies types that handle overflows with modulo arithmetic
[public static member constant] [edit]

digits

[static]

number of radix digits that can be represented without change
[public static member constant] [edit]

digits10

[static]

number of decimal digits that can be represented without change
[public static member constant] [edit]

max_digits10

[static] [C++11]

number of decimal digits necessary to differentiate all values of this type
[public static member constant] [edit]

radix

[static]

the radix or integer base used by the representation of the given type
[public static member constant] [edit]

min_exponent

[static]

one more than the smallest negative power of the radix that is a valid normalized floating-point value
[public static member constant] [edit]

min_exponent10

[static]

the smallest negative power of ten that is a valid normalized floating-point value
[public static member constant] [edit]

max_exponent

[static]

one more than the largest integer power of the radix that is a valid finite floating-point value
[public static member constant] [edit]

max_exponent10

[static]

the largest integer power of 10 that is a valid finite floating-point value
[public static member constant] [edit]

traps

[static]

identifies types which can cause arithmetic operations to trap
[public static member constant] [edit]

tinyness_before

[static]

identifies floating-point types that detect tinyness before rounding
[public static member constant] [edit]

[edit] Member functions

min

[static]

returns the smallest finite value of the given type
[public static member function] [edit]

lowest

[static] [C++11]

returns the lowest finite value of the given type
[public static member function] [edit]

max

[static]

returns the largest finite value of the given type
[public static member function] [edit]

epsilon

[static]

returns the difference between 1.0 and the next representable value of the given floating-point type
[public static member function] [edit]

round_error

[static]

returns the maximum rounding error of the given floating-point type
[public static member function] [edit]

infinity

[static]

returns the positive infinity value of the given floating-point type
[public static member function] [edit]

quiet_NaN

[static]

returns a quiet NaN value of the given floating-point type
[public static member function] [edit]

signaling_NaN

[static]

returns a signaling NaN value of the given floating-point type
[public static member function] [edit]

denorm_min

[static]

returns the smallest positive subnormal value of the given floating-point type
[public static member function] [edit]

[edit] Helper classes

[edit] Relationship with C library macro constants

Specialization
std::numeric_limits
where T is Members min[] lowest[]
[C++11] max[] radix
bool false false true 2
char CHAR_MIN CHAR_MIN CHAR_MAX 2
signed char SCHAR_MIN SCHAR_MIN SCHAR_MAX 2
unsigned char 0 0 UCHAR_MAX 2
wchar_t WCHAR_MIN WCHAR_MIN WCHAR_MAX 2
char8_t 0 0 UCHAR_MAX 2
char16_t 0 0 UINT_LEAST16_MAX 2
char32_t 0 0 UINT_LEAST32_MAX 2
short SHRT_MIN SHRT_MIN SHRT_MAX 2
signed short
unsigned short 0 0 USHRT_MAX 2
int INT_MIN INT_MIN INT_MAX 2
signed int
unsigned int 0 0 UINT_MAX 2
long LONG_MIN LONG_MIN LONG_MAX 2
signed long
unsigned long 0 0 ULONG_MAX 2
long long LLONG_MIN LLONG_MIN LLONG_MAX 2
signed long long
unsigned long long 0 0 ULLONG_MAX 2
Specialization
std::numeric_limits
where T is Members denorm_min[] min[] lowest[]
[C++11] max[] epsilon[] digits digits10
float FLT_TRUE_MIN FLT_MIN -FLT_MAX FLT_MAX FLT_EPSILON FLT_MANT_DIG FLT_DIG
double DBL_TRUE_MIN DBL_MIN -DBL_MAX DBL_MAX DBL_EPSILON DBL_MANT_DIG DBL_DIG
long double LDBL_TRUE_MIN LDBL_MIN -LDBL_MAX LDBL_MAX LDBL_EPSILON LDBL_MANT_DIG LDBL_DIG
Specialization
std::numeric_limits
where T is Members [continue] min_exponent min_exponent10 max_exponent max_exponent10 radix
float FLT_MIN_EXP FLT_MIN_10_EXP FLT_MAX_EXP FLT_MAX_10_EXP FLT_RADIX
double DBL_MIN_EXP DBL_MIN_10_EXP DBL_MAX_EXP DBL_MAX_10_EXP FLT_RADIX
long double LDBL_MIN_EXP LDBL_MIN_10_EXP LDBL_MAX_EXP LDBL_MAX_10_EXP FLT_RADIX

[edit] Example

#include #include   int main[] { std::cout

Chủ Đề