std::numeric_limits

简介: std::numeric_limits

numeric_limits 类模板提供了一种标准化的方式来查询算术类型的各种属性

比如

std::numeric_limits<int>::max()

numeric_limits 提供了专有的信息

#include <limits>
#include <iostream>
int main()
{
    std::cout
        << "type\t│ lowest()\t│ min()\t\t│ max()\n"
        << "bool\t│ "
        << std::numeric_limits<bool>::lowest() << "\t\t│ "
        << std::numeric_limits<bool>::min() << "\t\t│ "
        << std::numeric_limits<bool>::max() << '\n'
        << "uchar\t│ "
        << +std::numeric_limits<unsigned char>::lowest() << "\t\t│ "
        << +std::numeric_limits<unsigned char>::min() << "\t\t│ "
        << +std::numeric_limits<unsigned char>::max() << '\n'
        << "int\t│ "
        << std::numeric_limits<int>::lowest() << "\t│ "
        << std::numeric_limits<int>::min() << "\t│ "
        << std::numeric_limits<int>::max() << '\n'
        << "float\t│ "
        << std::numeric_limits<float>::lowest() << "\t│ "
        << std::numeric_limits<float>::min() << "\t│ "
        << std::numeric_limits<float>::max() << '\n'
        << "double\t│ "
        << std::numeric_limits<double>::lowest() << "\t│ "
        << std::numeric_limits<double>::min() << "\t│ "
        << std::numeric_limits<double>::max() << '\n';
}
目录
相关文章
|
9月前
|
编译器
ofstream错误:error: variable ‘std::ofstream ofs’ has initializer but incomplete type
ofstream错误:error: variable ‘std::ofstream ofs’ has initializer but incomplete type
150 1
Operator ‘==‘ cannot be applied to ‘int‘, ‘null‘
Operator ‘==‘ cannot be applied to ‘int‘, ‘null‘
error C2040: ‘n‘ : ‘int [1000]‘ differs in levels of indirection from ‘int ‘
error C2040: ‘n‘ : ‘int [1000]‘ differs in levels of indirection from ‘int ‘
144 0
HalconDotNet.HTupleAccessException:“‘Cannot convert to double array‘ when accessing ‘HalconDotNet.HT
HalconDotNet.HTupleAccessException:“‘Cannot convert to double array‘ when accessing ‘HalconDotNet.HT
|
机器学习/深度学习 PyTorch 算法框架/工具
解决Pytorch中RuntimeError: expected scalar type Double but found Float
解决Pytorch中RuntimeError: expected scalar type Double but found Float
2785 0
TypeError: randint() received an invalid combination of arguments - got (int, int, int), but expecte
TypeError: randint() received an invalid combination of arguments - got (int, int, int), but expecte
726 0
|
Java Linux
LINUX编译OPENJDK:The tested number of bits in the target (0) differs from the number of bits expected
LINUX编译OPENJDK:The tested number of bits in the target (0) differs from the number of bits expected
236 0
|
人工智能
Constant Palindrome Sum
Constant Palindrome Sum
|
编译器 Linux C语言
报错storage size of ‘sa’ isn’t known,当使用std=c99编译struct sigaction
报错storage size of ‘sa’ isn’t known,当使用std=c99编译struct sigaction
861 0
报错storage size of ‘sa’ isn’t known,当使用std=c99编译struct sigaction