class template
<limits>
std::numeric_limitstemplate <class T> numeric_limits;
Numeric limits type
Provides information about the properties of arithmetic types (either integral or floating-point) in the specific platform for which the library compiles.This class template is specialized for every fundamental arithmetic type, with its members describing the properties of type T. This template shall not be specialized for any other type.
bool
char
wchar_t
signed char
short int
int
long int
unsigned char
unsigned short int
unsigned int
unsigned long int
floating point types float
double
long double
For any other type, its default definition is used.
bool
char
char16_t
char32_t
wchar_t
signed char
short int
int
long int
long long int
unsigned char
unsigned short int
unsigned int
unsigned long int
unsigned long long int
floating point types float
double
long double
This template is also specialized for all
const
and/or
volatile
qualifications of these types, with the same values as their unqualified specializations.
For any other type, its default definition is used.
bool
true
for all arithmetic types (i.e., those for which numeric_limits is specialized).
false
for all other types. min() T Minimum finite value.
0
, depending on type. max() T Maximum finite value.
int
Number of digits (in decimal base) that can be represented without change.
int
Number of digits (in decimal base) required to ensure that values that differ are always differentiated. is_signed bool
true
if type is signed. is_integer bool
true
if type is integer. is_exact bool
true
if type uses exact representations. radix int
For integer types: base of the representation.
int
Minimum negative integer value such that radix raised to (min_exponent-1)
generates a normalized floating-point number.
int
Minimum negative integer value such that 10 raised to that power generates a normalized floating-point number.
int
Maximum integer value such that radix raised to (max_exponent-1)
generates a representable finite floating-point number.
int
Maximum integer value such that 10 raised to that power generates a normalized finite floating-point number.
bool
true
if the type has a representation for positive infinity. has_quiet_NaN bool
true
if the type has a representation for a quiet (non-signaling) "Not-a-Number". has_signaling_NaN bool
true
if the type has a representation for a signaling "Not-a-Number". has_denorm float_denorm_style Denormalized values (representations with a variable number of exponent bits). A type may have any of the following enum values:
bool
true
if a loss of accuracy is detected as a denormalization loss, rather than an inexact result. infinity() T Representation of positive infinity, if available. quiet_NaN() T Representation of quiet (non-signaling) "Not-a-Number", if available. signaling_NaN() T Representation of signaling "Not-a-Number", if available. denorm_min() T Minimum positive denormalized value.
min()
. is_iec559 bool
true
if the type adheres to IEC-559 / IEEE-754 standard.
true
; And infinity, quiet_NaN and signaling_NaN return some non-zero value. is_bounded bool
true
if the set of values represented by the type is finite. is_modulo bool
true
if the type is modulo. A type is modulo if it is possible to add two positive numbers and have a result that wraps around to a third number that is less. traps bool
true
if trapping is implemented for the type. tinyness_before bool
true
if tinyness is detected before rounding. round_style float_round_style Rounding style. A type may have any of the following enum values:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
template <class T> class numeric_limits {
public:
static const bool is_specialized = false;
static T min() throw();
static T max() throw();
static const int digits = 0;
static const int digits10 = 0;
static const bool is_signed = false;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 0;
static T epsilon() throw();
static T round_error() throw();
static const int min_exponent = 0;
static const int min_exponent10 = 0;
static const int max_exponent = 0;
static const int max_exponent10 = 0;
static const bool has_infinity = false;
static const bool has_quiet_NaN = false;
static const bool has_signaling_NaN = false;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
static T infinity() throw();
static T quiet_NaN() throw();
static T signaling_NaN() throw();
static T denorm_min() throw();
static const bool is_iec559 = false;
static const bool is_bounded = false;
static const bool is_modulo = false;
static const bool traps = false;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
template <class T> class numeric_limits {
public:
static constexpr bool is_specialized = false;
static constexpr T min() noexcept { return T(); }
static constexpr T max() noexcept { return T(); }
static constexpr T lowest() noexcept { return T(); }
static constexpr int digits = 0;
static constexpr int digits10 = 0;
static constexpr bool is_signed = false;
static constexpr bool is_integer = false;
static constexpr bool is_exact = false;
static constexpr int radix = 0;
static constexpr T epsilon() noexcept { return T(); }
static constexpr T round_error() noexcept { return T(); }
static constexpr int min_exponent = 0;
static constexpr int min_exponent10 = 0;
static constexpr int max_exponent = 0;
static constexpr int max_exponent10 = 0;
static constexpr bool has_infinity = false;
static constexpr bool has_quiet_NaN = false;
static constexpr bool has_signaling_NaN = false;
static constexpr float_denorm_style has_denorm = denorm_absent;
static constexpr bool has_denorm_loss = false;
static constexpr T infinity() noexcept { return T(); }
static constexpr T quiet_NaN() noexcept { return T(); }
static constexpr T signaling_NaN() noexcept { return T(); }
static constexpr T denorm_min() noexcept { return T(); }
static constexpr bool is_iec559 = false;
static constexpr bool is_bounded = false;
static constexpr bool is_modulo = false;
static constexpr bool traps = false;
static constexpr bool tinyness_before = false;
static constexpr float_round_style round_style = round_toward_zero;
};
All specializations shall also provide these values as
constant expressions.
1
2
3
4
5
6
7
8
9
10
11
12
13
// numeric_limits example
#include <iostream> // std::cout
#include <limits> // std::numeric_limits
int main () {
std::cout << std::boolalpha;
std::cout << "Minimum value for int: " << std::numeric_limits<int>::min() << '\n';
std::cout << "Maximum value for int: " << std::numeric_limits<int>::max() << '\n';
std::cout << "int is signed: " << std::numeric_limits<int>::is_signed << '\n';
std::cout << "Non-sign bits in int: " << std::numeric_limits<int>::digits << '\n';
std::cout << "int has infinity: " << std::numeric_limits<int>::has_infinity << '\n';
return 0;
}
Minimum value for int: -2147483648 Maximum value for int: 2147483647 int is signed: true Non-sign bits in int: 31 int has infinity: false
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4