#include "numeric_limits.hpp"
#include <limits>
#include <iostream>

//////////////////////////////////////////////////////////////////////
/* reference:
http://www.cplusplus.com/reference/limits/numeric_limits/
https://msdn.microsoft.com/en-us/library/c707ct0t.aspx
*/
int test_numeric_limits_1()
{
std::cout << std::boolalpha;
std::cout << "Minimum value for int: " << std::numeric_limits<int>::min() << std::endl;
std::cout << "Maximum value for int: " << std::numeric_limits<int>::max() << std::endl;
std::cout << "int is signed: " << std::numeric_limits<int>::is_signed << std::endl;
std::cout << "Non-sign bits in int: " << std::numeric_limits<int>::digits << std::endl;
std::cout << "int has infinity: " << std::numeric_limits<int>::has_infinity << std::endl;

std::cout << "Minimum value for float: " << std::numeric_limits<float>::min() << std::endl; // min returns the smallest positive value the type can encode, not the lowest
std::cout << "Lowest value for float: " << std::numeric_limits<float>::lowest() << std::endl; // the lowest value
std::cout << "Maximum value for float: " << std::numeric_limits<float>::max() << std::endl;
std::cout << "float is signed: " << std::numeric_limits<float>::is_signed << std::endl;
std::cout << "Non-sign bits in float: " << std::numeric_limits<float>::digits << std::endl;
std::cout << "float has infinity: " << std::numeric_limits<float>::has_infinity << std::endl;

std::cout << "Minimum value for unsigned short: " << std::numeric_limits<unsigned short>::min() << std::endl;
std::cout << "Maximum value for unsigned short: " << std::numeric_limits<unsigned short>::max() << std::endl;

std::cout << "is_specialized(float): " << std::numeric_limits<float>::is_specialized << std::endl;
std::cout << "is_integer(float): " << std::numeric_limits<float>::is_integer << std::endl;
std::cout << "is_exact(float): " << std::numeric_limits<float>::is_exact << std::endl;
std::cout << "is_bounded(float): " << std::numeric_limits<float>::is_bounded << std::endl;
std::cout << "is_modulo(float): " << std::numeric_limits<float>::is_modulo << std::endl;
std::cout << "is_iec559(float): " << std::numeric_limits<float>::is_iec559 << std::endl;
std::cout << "digits10(float): " << std::numeric_limits<float>::digits10 << std::endl;
std::cout << "radix(float): " << std::numeric_limits<float>::radix << std::endl;
std::cout << "min_exponent(float): " << std::numeric_limits<float>::min_exponent << std::endl;
std::cout << "max_exponent(float): " << std::numeric_limits<float>::max_exponent << std::endl;
std::cout << "min_exponent10(float): " << std::numeric_limits<float>::min_exponent10 << std::endl;
std::cout << "max_exponent10(float): " << std::numeric_limits<float>::max_exponent10 << std::endl;
std::cout << "epsilon(float): " << std::numeric_limits<float>::epsilon() << std::endl;
std::cout << "round_style(float): " << std::numeric_limits<float>::round_style << std::endl;

std::cout << "The smallest nonzero denormalized value for float: "
<< std::numeric_limits<float>::denorm_min()<< std::endl;
std::cout << "The difference between 1 and the smallest value greater than 1 for float: "
<< std::numeric_limits<float>::epsilon()<< std::endl;
std::cout << "Whether float objects allow denormalized values: "
<< std::numeric_limits<float>::has_denorm << std::endl;
std::cout << "Whether float objects can detect denormalized loss: "
<< std::numeric_limits<float>::has_denorm_loss << std::endl;
std::cout << "Whether float objects have quiet_NaN: "
<< std::numeric_limits<float>::has_quiet_NaN << std::endl;
std::cout << "Whether float objects have a signaling_NaN: "
<< std::numeric_limits<float>::has_signaling_NaN << std::endl;
std::cout << "The base for type float is: "
<< std::numeric_limits<float>::radix << std::endl;
std::cout << "The maximum rounding error for type float is: "
<< std::numeric_limits<float>::round_error() << std::endl;
std::cout << "The rounding style for a double type is: "
<< std::numeric_limits<double>::round_style << std::endl;
std::cout << "The signaling NaN for type float is: "
<< std::numeric_limits<float>::signaling_NaN() << std::endl;
std::cout << "Whether float types can detect tinyness before rounding: "
<< std::numeric_limits<float>::tinyness_before << std::endl;
std::cout << "Whether float types have implemented trapping: "
<< std::numeric_limits<float>::traps << std::endl;

return 0;
}

c++常见变量的极值的更多相关文章

  1. Makefile 隐含规则,模式规则,常见变量

     隐含规则复杂的Makefile一般会使用隐含规则内的变量来简化编译处理.将隐含规则中使用的变量分成两种:一种是命令相关的,如“CC”:一种是参数相关的,如“CFLAGS”.这些变量都是大写表示. 常 ...

  2. 跟厂长学PHP7内核(七):常见变量类型的基本结构

    上篇文章讲述了变量的存储结构zval,今天我们就来学习一下几个常见变量类型的基本结构. 一.类型一览 zval中的u1.v.type用来存储变量的类型,而zval.value存储的是不同类型对应的值, ...

  3. PHP7内核(七):常见变量类型的基本结构

    上篇文章讲述了变量的存储结构zval,今天我们就来学习一下几个常见变量类型的基本结构. 一.类型一览 zval中的u1.v.type用来存储变量的类型,而zval.value存储的是不同类型对应的值, ...

  4. makefile常用指令和常见变量。

    引用文章A:http://blog.csdn.net/liang13664759/article/details/1771246 文章介绍:非常详细的文章,讲解上都是比较基础的知识. 本文可能会持续更 ...

  5. javascript总结4:javascript常见变量

    1 javascript变量 定义:变量在计算机中,是用于存储信息的"容器". 2  使用方法: 2-1 定义变量: var n1; 2-2 变量赋值: var n2=23.45; ...

  6. 【windows】常见的系统环境变量,如%appdata%表示什么意思

    原文:[windows]常见的系统环境变量,如%appdata%表示什么意思 1.介绍 %appdata%就代表了C:Users\用户名\AppData\Roaming这个文件夹. “%”是系统变量的 ...

  7. shell的变量以及常见符号

    shell的变量以及常见符号 常见变量 不同于其它语言需要先声明变量,shell的变量直接使用 eg:      a=15 调用变量的话 $a 或者 ${a} $? #判断上一条命令执行的是否成功 0 ...

  8. shell学习笔记1: shell 中的变量与常见符号使用方法

    变量 声明即用 a=2 b="123" 调用 ${varName}或者 $varName echo $b echo ${a} 常见变量 $?:判断上一个语句是否成功 $0:执行脚本 ...

  9. 5.Powershell变量

    在指令执行过程中,会有一些数据产生,这些数据被用于以后的语句,需要一个存储单元暂时的存放这些数据,这个时候定义一个变量来存储数据.例如$string = “Hello Powershell!” Pow ...

随机推荐

  1. python之计算机硬件基本认知_数据单位_进制间转换_数的原码反码补码

    一:计算机硬件基本认知 cpu:   中央处理器.   相当于人的大脑.运算中心,控制中心. 内存:  临时存储数据. 优点:读取速度快,缺点:容量小,造价高,断电即消失. 硬盘:  长期存储数据. ...

  2. Hadoop 2.x 版本的单机模式安装

    Hadoop 2.x 版本比起之前的版本在Hadoop和MapReduce上做了许多变化,主要的变化之一,是JobTracker被ResourceManager和ApplicationManager所 ...

  3. XML的介绍使用

    一.什么是XML? XML,Extensible Markup Language,扩展性标识语言.文件的后缀名为:.xml.就像HTML的作用是显示数据,XML的作用是传输和存储数据. 据说,java ...

  4. Tornado异步非阻塞的使用以及原理

    Tornado 和现在的主流 Web 服务器框架(包括大多数 Python 的框架)有着明显的区别:它是非阻塞式服务器,而且速度相当快.得利于其 非阻塞的方式和对 epoll 的运用,Tornado ...

  5. docker:构建nginx+php-fpm镜像(一):构建nginx自启动镜像

    步骤一:手动安装nginx环境,并记录全过程: #使用yum更新系统 yum -y update   #下面编译安装tengine,查看有哪些包需要安装 #安装wget包,用于获取安装软件包 yum ...

  6. git 本地修改、撤消操作

    // 撤消本地文件的修改,还原到最近版本 git checkout -- * 是撤销从上次提交之后所做的所有修改 git checkout -- <filaname> 是撤销从上次提交之后 ...

  7. VS2015Git 源代码工具使用

    1. 首先到源代码托管平台申请个账户:https://git.oschina.net/ 2.创建流程图: 2.1 开始创建项目: 2.2 3. 4. 作者:江宁织造 qq空间:苦心孤诣博客:http: ...

  8. primo驱动启动顺序

    primo驱动启动顺序HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ServiceGroupOrderSystem ReservedEMSWdfLoa ...

  9. pandas模块实现小爬虫功能-转载

    pandas模块实现小爬虫功能 安装 pip3 install pandas 爬虫代码 import pandas as pd df = pd.read_html("http://www.a ...

  10. DP基础练习(4.21)

    数塔 Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的: 有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少? ...