std::numeric_limits::min
STD::数字[医]限制::最低限度
static T min( | | (until C++11) |
---|---|---|
static constexpr T min( | | (since C++11) |
返回可由数值类型表示的最小有限值。T
...
对于具有反规范化的浮点类型,min
返回最小正归一化值。请注意,此行为可能是意外的。
,特别是当与…的行为相比较时。min
对于积分类型。若要查找值不少于此值的值,请使用numeric_limits::lowest
...
min
仅对有界类型和无符号类型有意义,也就是说,表示无限负值集的类型没有意义最小值。
返回值
T | std::numeric_limits |
---|---|
/* non-specialized */ | T( |
bool | false |
char | CHAR_MIN |
signed char | SCHAR_MIN |
unsigned char | 0 |
wchar_t | WCHAR_MIN |
char16_t | 0 |
char32_t | 0 |
short | SHRT_MIN |
unsigned short | 0 |
int | INT_MIN |
unsigned int | 0 |
long | LONG_MIN |
unsigned long | 0 |
long long | LLONG_MIN |
unsigned long long | 0 |
float | FLT_MIN |
double | DBL_MIN |
long double | LDBL_MIN |
例外
(none) | (until C++11) |
---|---|
noexcept specification: noexcept | (since C++11) |
例
演示是否使用类型类型,以及整数类型和浮点数类型之间的结果符号的差异。
二次
#include <limits>
#include <cstddef>
#include <iostream>
int main()
{
std::cout
<< "short: " << std::dec << std::numeric_limits<short>::min()
<< " or " << std::hex << std::showbase
<< std::numeric_limits<short>::min() << '\n'
<< "int: " << std::dec << std::numeric_limits<int>::min() << std::showbase
<< " or " << std::hex << std::numeric_limits<int>::min() << '\n' << std::dec
<< "ptrdiff_t: " << std::numeric_limits<std::ptrdiff_t>::min() << std::showbase
<< " or " << std::hex << std::numeric_limits<std::ptrdiff_t>::min() << '\n'
<< "float: " << std::numeric_limits<float>::min()
<< " or " << std::hexfloat << std::numeric_limits<float>::min() << '\n'
<< "double: " << std::defaultfloat << std::numeric_limits<double>::min()
<< " or " << std::hexfloat << std::numeric_limits<double>::min() << '\n';
}
二次
可能的产出:
二次
short: -32768 or 0x8000
int: -2147483648 or 0x80000000
ptrdiff_t: -9223372036854775808 or 0x8000000000000000
float: 1.17549e-38 or 0x1p-126
double: 2.22507e-308 or 0x1p-1022
二次
另见
lowest static | returns the lowest finite value of the given type (public static member function) |
---|---|
denorm_min static | returns the smallest positive subnormal value of the given floating-point type (public static member function) |
max static | returns the largest finite value of the given type (public static member function) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。