在线文档教程
C++
应用 | Utilities

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仅对有界类型和无符号类型有意义,也就是说,表示无限负值集的类型没有意义最小值。

返回值

Tstd::numeric_limits::min()
/* non-specialized */T(
boolfalse
charCHAR_MIN
signed charSCHAR_MIN
unsigned char​0​
wchar_tWCHAR_MIN
char16_t​0​
char32_t​0​
shortSHRT_MIN
unsigned short​0​
intINT_MIN
unsigned int​0​
longLONG_MIN
unsigned long​0​
long longLLONG_MIN
unsigned long long​0​
floatFLT_MIN
doubleDBL_MIN
long doubleLDBL_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 staticreturns the lowest finite value of the given type (public static member function)
denorm_min staticreturns the smallest positive subnormal value of the given floating-point type (public static member function)
max staticreturns the largest finite value of the given type (public static member function)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/type/NUMERIC[医]限值/分钟