- 浏览: 352982 次
- 性别:
- 来自: 苏州
文章分类
- 全部博客 (335)
- C++ (190)
- 设计模式 (43)
- 数据库技术 (5)
- 网络编程 (11)
- 自动化测试 (6)
- Linux (13)
- OpenSSL (10)
- MS Crypt API (5)
- SCM (2)
- English (4)
- Android (10)
- EMV规范 (1)
- Saturn Platform (0)
- C (10)
- SQL (2)
- ASP.NET (3)
- 英语口语学习 (3)
- 调试工具 (21)
- 编译技术 (5)
- UML (1)
- 项目管理 (5)
- 敏捷开发 (2)
- Http Server (6)
- 代码审查、代码分析 (5)
- 面试基础 (10)
- 重点知识 (16)
- STL (6)
- Efficient C++资料 (8)
- 数据结构和算法 (7)
- 读书笔记 (0)
- 开源项目 (4)
- 多线程 (2)
- Console App (6)
- 个人开源项目 (4)
- IBM DevelopWorks (4)
- Java (16)
- 内存泄漏相关调试和检测 (13)
- 软件测试相关技术 (2)
- C# (11)
- Apple Related (1)
- 软件测试和管理 (2)
- EMV (1)
- Python (1)
- Node.js (6)
- JavaScript (5)
- VUE (1)
- Frontend (1)
- Backend (4)
- RESTful API (3)
- Firebase (3)
最新评论
-
u013189503:
来个密码吧
[C++][Logging] 项目中写日志模块的实现 -
wyf_vc:
来个密码啊!!
[C++][Logging] 项目中写日志模块的实现
From:http://www.cplusplus.com/reference/std/limits/numeric_limits/
numeric_limits
浮点数据精度判断
float x=0.0;
float y=0.0f;
if ( abs(x -y) <= numeric_limits<float>::epsilon() )
{
...
}
<limits>
Numeric limits type
This class is specialized for each of the fundamental types, with its members returning or set to the different values that define the properties that type has in the specific platform in which it compiles.
For all the other types (non-fundamental types) a specialization of this class should not exist.
The non-specialized class is defined as:
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 |
|
A specialization exists for each of the fundamental types: bool, char, signed char, unsigned char, wchar_t, short, unsigned short, int, unsigned int, long, unsigned long, float, double and long double. These specializations define the specific values for the different static const members, and all have is_specialized defined as true.
Members
is_specialized | bool | true on all specializations of the type, false in the non-specialized version. |
min() | T | Minimum finite value. For floating types with denormalization (variable number of exponent bits): minimum positive normalized value. Equivalent to CHAR_MIN, SCHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN, FLT_MIN, DBL_MIN, LDBL_MIN or 0, depending on type. |
max() | T | Maximum finite value. Equivalent to CHAR_MAX, SCHAR_MAX, UCHAR_MAX, SHRT_MAX, USHRT_MAX, INT_MAX, UINT_MAX, LONG_MAX, ULONG_MAX, FLT_MAX, DBL_MAX or LDBL_MAX, depending on type. |
digits | int | For integer types: number of non-sign bits (radix base digits) in the representation. For floating types: number of digits (in radix base) in the mantissa (equivalent to FLT_MANT_DIG, DBL_MANT_DIG or LDBL_MANT_DIG). |
digits10 | int | Number of digits (in decimal base) that can be represented without change. Equivalent to FLT_DIG, DBL_DIG or LDBL_DIG for floating types. |
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. For floating types: base of the exponent of the representation (equivalent to FLT_RADIX). |
epsilon() | T | Machine epsilon (the difference between 1 and the least value greater than 1 that is representable). Equivalent to FLT_EPSILON, DBL_EPSILON or LDBL_EPSILON for floating types. |
round_error() | T | Measure of the maximum rounding error. |
min_exponent | int | Minimum negative integer value for the exponent that generates a normalized floating-point number. Equivalent to FLT_MIN_EXP, DBL_MIN_EXP or LDBL_MIN_EXP for floating types. |
min_exponent10 | int | Minimum negative integer value such that 10 raised to that power generates a normalized floating-point number. Equivalent to FLT_MIN_10_EXP, DBL_MIN_10_EXP or LDBL_MIN_10_EXP for floating types. |
max_exponent | int | Maximum integer value for the exponent that generates a normalized floating-point number. Equivalent to FLT_MAX_EXP, DBL_MAX_EXP or LDBL_MAX_EXP for floating types. |
max_exponent10 | int | Maximum integer value such that 10 raised to that power generates a normalized finite floating-point number. Equivalent to FLT_MAX_10_EXP, DBL_MAX_10_EXP or LDBL_MAX_10_EXP for floating types. |
has_infinity | 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: denorm_absent, if it does not allow denormalized values. denorm_present, if it allows denormalized values. denorm_indeterminate, if indeterminate at compile time. |
has_denorm_loss | 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. For types not allowing denormalized values: same as min(). |
is_iec559() | T |
true if the type adheres to IEC-559 / IEEE-754 standard. An IEC-559 type always has has_infinity, has_quiet_NaN and has_signaling_NaN set to 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: round_toward_zero, if it rounds toward zero. round_to_nearest, if it rounds to the nearest representable value. round_toward_infinity, if it rounds toward infinity. round_toward_neg_infinity, if it rounds toward negative infinity. round_indeterminate, if the rounding style is indeterminable at compile time. |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Possible output:
Minimum value for int: -2147483648 Maximum value for int: 2147483647 int is signed: true Non-sign bits in int: 31 int has infinity: false |
See also
climits (limits.h) | Sizes of integral types (header) |
cfloat (float.h) | Characteristics of floating-point types (header) |
Test:
|
发表评论
-
FreeRTOS
2022-03-05 16:31 202Ref https://blog.csdn.net/weix ... -
串口通讯相关
2018-11-02 13:44 357https://bbs.csdn.net/wap/topics ... -
[转]C++验证IP是否可以PING通
2018-10-30 17:54 1217https://www.cnblogs.com/guoyz13 ... -
C++/MFC 換皮膚
2018-10-20 11:05 419https://blog.csdn.net/u01123991 ... -
WinCE 截屏 - C++ 代碼
2018-08-31 09:45 515// this function create a bmp ... -
Android NDK搭建環境
2017-11-27 13:25 524https://www.cnblogs.com/ut2016- ... -
8583协议相关
2017-10-17 13:38 5108583相关资料,整理中... -
Java高级应用之JNI
2017-06-19 09:00 534参考link http://www.cnblogs.com/l ... -
C++实现ping功能
2017-04-18 11:21 2019基础知识 ping的过程是向目的IP发送一个type=8的I ... -
OpenSSL 编译环境搭建
2017-03-27 15:01 8491 安裝VS2008到 c:\Program Files (x ... -
最优非对称加密填充(OAEP)
2017-03-25 14:53 1502OpenSSL命令---rsautl http://blog. ... -
[Platform Builder] 设置SVM OS build Env
2016-11-10 11:39 01 copy one OSDesign Project to ... -
[Windows] System Error Codes(GetLastError )0-----5999
2016-10-26 13:28 1830ERROR_SUCCESS 0 (0x0) T ... -
开源Windows驱动程序框架
2016-09-17 21:35 808转自 http://code.csdn.net/news/28 ... -
c/c++代码中执行cmd命令
2016-09-14 14:50 1804转自 http://blog.csdn.net/slixinx ... -
C#使用C++标准DLL实例(包含callback)
2016-09-11 19:44 995C++编写标准Win32DLL如下 头文件 /***** ... -
C#调用C++的DLL搜集整理的所有数据类型转换方式
2016-09-09 16:07 921转自 http://www.cnblogs.com/zeroo ... -
WinCE CPU使用率计算 测试工具
2016-09-08 16:14 931转自 http://blog.csdn.net/jan ... -
switch在C++与C#中的一些差异
2016-09-08 15:19 751参考链接 http://blog.csdn.net/weiwe ... -
C++ 鼠标模拟程序
2016-09-04 12:09 1526转自 http://blog.csdn.net/weixinh ...
相关推荐
C++读取STL文件,输出所有三角形的顶点坐标
STL学习教程,
STL 最新源代码
采用C++11实现一款简易的STL标准库,既是C++STL的一个子集(裁剪了一些容器和算法)又是一个超集(增加了一些容器和算法) 目的:练习数据结构与算法和C++ Template编程 编译环境:VS2013及以上版本
c++ stl操作常见的函数重载结构体优先队列排序等
C++ STL实现包含常用stl模板的手动实现仅供参考
STL课件_C++_课件stl_c++课件_源码.zip
用于STL文件读取与显示的C语言程序,简单方便实用。
C++标准模板库(STL),适合想要深入学习C++编程的小伙伴。
哈希表应用C++_STL_hash 哈希表应用C++_STL_hash 哈希表应用C++_STL_hash
Filled with proven wisdom that comes only from experience. Its clear
是find_if的使用方法,但是文件名是Test_find,懒得改成Test_find_if了。代码没什么注释,既然会用STL那就一定看得明白。
c++的标准模板STL操作,对初学者很有用,帮助更快入们
侯捷讲STL的课件,里面还有我做的一些笔记
stlshow_stl分层_STL分层_stlmatlab_STL切片_stl分层_源码.rar.rar
stlshow_stl分层_STL分层_stlmatlab_STL切片_stl分层.zip
用于三维光学形貌扫描完成后,生成的stl文件的读取,并形成俯视投影云图
一个学习STL 中Map的类,主要实现stl::map的查找、删除、增加等
c++入门资料
STL 是 C++ 标准库的一部分,不用单独安装。 C++ 对模板(Template)支持得很好,STL 就是借助模板把常用的数据结构及其算法都实现了一遍,并且做到了数据结构和算法的分离。例如,vector 的底层为顺序表(数组),...