当前位置:网站首页>numeric_ Limits the range and related attributes of each data type learned
numeric_ Limits the range and related attributes of each data type learned
2022-07-28 03:53:00 【I washed my feet in Bangong Lake】
c++ There are many data types in , Each data type has a range and related attributes , such as short The type is 16, Range from -32768 To 32767,int The range is from -2147483648 To 2147483647 wait , Because the length of each data type is different , The scope is very different , So I didn't remember their specific scope , and numeric_limits You can view the range size of each data type , It is also convenient to use , Let's look at specific examples :
Member constants
[ static state ] | To identify std::numeric_limits Whether to specialize for this type ( Expose static member constants ) |
[ static state ] | Identify signed types ( Expose static member constants ) |
[ static state ] | Identify integer types ( Expose static member constants ) |
[ static state ] | Identify the type of accurate representation ( Expose static member constants ) |
[ static state ] | Discrimination can represent special values “ Positive infinity ” Floating point type of ( Expose static member constants ) |
[ static state ] | Discrimination can represent special values “ Quiet non number ”( NaN ) Floating point type of ( Expose static member constants ) |
[ static state ] | Discrimination can represent special values “ The number of non letters sent ”( NaN ) Floating point type of ( Expose static member constants ) |
[ static state ] | The informal style used to identify floating-point types ( Expose static member constants ) |
[ static state ] | Identify whether the floating-point type detects an irregular loss of precision , Not inaccurate results ( Expose static member constants ) |
[ static state ] | The rounding pattern used to identify the type ( Expose static member constants ) |
[ static state ] | To identify IEC 559/IEEE 754 Floating point type ( Expose static member constants ) |
[ static state ] | Identify the types that represent finite value sets ( Expose static member constants ) |
[ static state ] | Identify the type of overflow handled by modular arithmetic ( Expose static member constants ) |
[ static state ] | Capable of being represented unchanged radix digit ( Expose static member constants ) |
[ static state ] | The number of decimal digits that can be represented unchanged ( Expose static member constants ) |
[ static state ] (C++11) | The number of decimal digits required to distinguish all values of this type ( Expose static member constants ) |
[ static state ] | The base or integer base used for the representation of a given type ( Expose static member constants ) |
[ static state ] | The power of the base is the smallest negative number plus one of the legal normal floating-point values ( Expose static member constants ) |
[ static state ] | 10 The power of this number is the minimum negative number of the legal normal floating-point value ( Expose static member constants ) |
[ static state ] | The power of the number of times at the bottom is the maximum integer of the legal finite floating-point value plus one ( Expose static member constants ) |
[ static state ] | 10 The power of this number is the largest integer of a legal finite floating-point value ( Expose static member constants ) |
[ static state ] | Identify the types that may cause traps in arithmetic operations ( Expose static member constants ) |
[ static state ] | Identify and detect whether the floating-point type is irregular before rounding ( Expose static member constants ) |
Member functions
[ static state ] | Returns the minimum finite value of a given type ( Expose static member functions ) |
[ static state ] (C++11) | Returns the lowest finite value of a given type ( Expose static member functions ) |
[ static state ] | Returns the maximum finite value of a given type ( Expose static member functions ) |
[ static state ] | return 1.0 The difference from the next representable value of a given type ( Expose static member functions ) |
[ static state ] | Returns the maximum rounding error for a given floating-point type ( Expose static member functions ) |
[ static state ] | Returns a positive infinity value of a given type ( Expose static member functions ) |
[ static state ] | Returns the value of the given floating-point type NaN value ( Expose static member functions ) |
[ static state ] | Returns the sending of a given floating-point type NaN ( Expose static member functions ) |
[ static state ] | Returns the minimum positive non normal value of a given floating-point type ( Expose static member functions ) |
Code example :
#include <iostream>
#include <limits>
using namespace std;
int main()
{
cout << std::boolalpha;
std::cout << "type\t\t│ lowest()\t│ min()\t\t│ max()\n";
std::cout << "bool\t\t│ " << std::numeric_limits<bool>::lowest() << "\t\t│ "
<< std::numeric_limits<bool>::min() << "\t\t│ "
<< std::numeric_limits<bool>::max() << '\n';
std::cout << "char\t\t│ " << std::numeric_limits<char>::lowest() << "\t\t│ "
<< std::numeric_limits<char>::min() << "\t\t│ "
<< std::numeric_limits<char>::max() << '\n';
std::cout << "float\t\t│ " << std::numeric_limits<float>::lowest() << "\t│ "
<< std::numeric_limits<float>::min() << "\t│ "
<< std::numeric_limits<float>::max() << '\n';
std::cout << "double\t\t│ " << std::numeric_limits<double>::lowest() << "\t│ "
<< std::numeric_limits<double>::min() << "\t│ "
<< std::numeric_limits<double>::max() << '\n';
std::cout << "wchar_t\t\t│ " << std::numeric_limits<wchar_t>::lowest() << "\t\t│ "
<< std::numeric_limits<wchar_t>::min() << "\t\t│ "
<< std::numeric_limits<wchar_t>::max() << '\n';
std::cout << "char16_t\t│ " << std::numeric_limits<char16_t>::lowest() << "\t\t│ "
<< std::numeric_limits<char16_t>::min() << "\t\t│ "
<< std::numeric_limits<char16_t>::max() << '\n';
std::cout << "char32_t\t│ " << std::numeric_limits<char32_t>::lowest() << "\t\t│ "
<< std::numeric_limits<char32_t>::min() << "\t\t│ "
<< std::numeric_limits<char32_t>::max() << '\n';
std::cout << "short\t\t│ " << std::numeric_limits<short>::lowest() << "\t│ "
<< std::numeric_limits<short>::min() << "\t│ "
<< std::numeric_limits<short>::max() << '\n';
std::cout << "signed short\t│ " << std::numeric_limits<signed short>::lowest() << "\t│ "
<< std::numeric_limits<signed short>::min() << "\t│ "
<< std::numeric_limits<signed short>::max() << '\n';
std::cout << "unsigned short\t│ " << std::numeric_limits<unsigned short>::lowest() << "\t\t│ "
<< std::numeric_limits<unsigned short>::min() << "\t\t│ "
<< std::numeric_limits<unsigned short>::max() << '\n';
std::cout << "int\t\t│ " << std::numeric_limits<int>::lowest() << "\t│ "
<< std::numeric_limits<int>::min() << "\t│ "
<< std::numeric_limits<int>::max() << '\n';
std::cout << "signed int\t│ " << std::numeric_limits<signed int>::lowest() << "\t│ "
<< std::numeric_limits<signed int>::min() << "\t│ "
<< std::numeric_limits<signed int>::max() << '\n';
std::cout << "unsigned int\t│ " << std::numeric_limits<unsigned int>::lowest() << "\t\t│ "
<< std::numeric_limits<unsigned int>::min() << "\t\t│ "
<< std::numeric_limits<unsigned int>::max() << '\n';
std::cout << "long\t\t│ " << std::numeric_limits<long>::lowest() << "\t│ "
<< std::numeric_limits<long>::min() << "\t│ "
<< std::numeric_limits<long>::max() << '\n';
std::cout << "signed long\t│ " << std::numeric_limits<signed long>::lowest() << "\t│ "
<< std::numeric_limits<signed long>::min() << "\t│ "
<< std::numeric_limits<signed long>::max() << '\n';
std::cout << "unsigned long\t│ " << std::numeric_limits<unsigned long>::lowest() << "\t\t│ "
<< std::numeric_limits<unsigned long>::min() << "\t\t│ "
<< std::numeric_limits<unsigned long>::max() << '\n';
std::cout << "long long\t│ " << std::numeric_limits<long long>::lowest() << "\t\t│ "
<< std::numeric_limits<long long>::min() << "\t\t│ "
<< std::numeric_limits<long long>::max() << '\n';
std::cout << "signed long long│ " << std::numeric_limits<signed long long>::lowest() << "\t\t│ "
<< std::numeric_limits<signed long long>::min() << "\t\t│ "
<< std::numeric_limits<signed long long>::max() << '\n';
std::cout << "unsigned long long│ " << std::numeric_limits<unsigned long long>::lowest() << "\t\t│ "
<< std::numeric_limits<unsigned long long>::min() << "\t\t│ "
<< std::numeric_limits<unsigned long long>::max() << '\n';
cout << "Hello World!" << endl;
return 0;
}
Running results :

Reference resources :
std::numeric_limits - cppreference.com
https://cplusplus.com/reference/limits/numeric_limits/
边栏推荐
- Dynamic programming - 474. One and zero
- [wrong question]
- [paper notes] mobile robot autonomous navigation experimental platform based on deep learning
- 数据挖掘-01
- 【OPENVX】对象基本使用之vx_image
- ES6 from entry to mastery 07: Deconstruction assignment
- Detailed explanation of pointer written test questions (C language)
- Leetcode58. Length of the last word
- Embedded development: tips and techniques -- the best practice of defensive programming with C
- Appnium -- app automated test tool
猜你喜欢

高等数学(第七版)同济大学 习题3-6 个人解答

Capacity expansion and reduction of RBD block storage device (VI)

An article grasps the calculation and processing of date data in PostgreSQL

一文读懂Plato Farm的ePLATO,以及其高溢价缘由

What is tor? What is the use of tor browser update?

Data mining-01
![[paper notes] mobile robot autonomous navigation experimental platform based on deep learning](/img/6a/7f0c2b2a53332636f3172bc3b0b74d.png)
[paper notes] mobile robot autonomous navigation experimental platform based on deep learning

Build an "industrial brain" and improve the park's operation, management and service capabilities with "digitalization"!

Prefix-Tuning: Optimizing Continuous Prompts for Generation

静态博客搭建工具汇总
随机推荐
Tungsten Fabric SDN — BGP as a Service
Xctf attack and defense world web master advanced area php2
Practical scripts of mangopapa (contents)
[错题]Mocha and Railgun
Differences among BRD, MRD and PRD
pip-script. py‘ is not present Verifying transaction: failed
高等数学(第七版)同济大学 习题3-5 个人解答
Developing rc522 module based on c8t6 chip to realize breathing lamp
常用的接口测试工具
Swift中的协议
做自动化测试,你后悔了吗?
常用的弱网测试工具
Dynamic planning - 1049. Weight of the last stone II
Do you regret doing automated testing?
Data rich Computing: m.2 meets AI at the edge
LeetCode_ 409_ Longest palindrome string
简单、好用的性能测试工具推荐
Protocols in swift
[openvx] VX for basic use of objects_ matrix
Xctf attack and defense world web master advanced area unserialize3