#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. JS ajax请求参数格式( formData 、serialize)

    $("#importBtn").click(function(){ if($("#conId").val() == ""){ alert(& ...

  2. 创建一个dynamics 365 CRM online plugin (五) - Images in Plugin

    Snapshots of the primary entity's attributes from database before(pre) and after (post) the core pla ...

  3. docker 创建docker用户组,应用用户加入用户组

    在Linux系统下使用docker,为了避免每次输入命令都需要sudo,可以把用户加入docker用户组 创建docker用户组 sudo groupadd docker 普通用户加入docker用户 ...

  4. 1、Nexus安装

    1.nexus 下载地址: https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.5-02-bundle.tar.g ...

  5. DS-1

    一.作业题目 仿照三元组或复数的抽象数据类型写出有理数抽象数据类型的描述 (有理数是其分子.分母均为整数且分母不为零的分数). 有理数基本运算: 构造有理数T,元素e1,e2分别被赋以分子.分母值 销 ...

  6. Linux简单线程池实现(带源码)

    这里给个线程池的实现代码,里面带有个应用小例子,方便学习使用,代码 GCC 编译可用.参照代码看下面介绍的线程池原理跟容易接受,百度云下载链接: http://pan.baidu.com/s/1i3z ...

  7. 错误界面 SQL2008备份集中的数据库备份与现有的数据库不同,错误号码:3154。

    转载来源  https://blog.csdn.net/zaocha321/article/details/8466735 因为我也用这个方法成功了.所以记录下来 错误界面 SQL2005备份集中的数 ...

  8. 《剑指offer(第二版)》面试题64——求1+2+...+n

    一.题目描述 求1+2+3+...+n,要求不能使用乘除法.for.while.if.else.switch.case等关键字以及条件判断语句 (即三元运算符,A? B : C) 二.题解 虽然求和问 ...

  9. web页面性能

    一.资源压缩合并,减少HTTP请求 二.非核心代码异步加载 1.异步加载的方式 动态脚本加载 defer async 2.异步加载的区别 (1)defer是在HTML解析完之后才会执行,如果是多个,按 ...

  10. 超级简单的Memcache入门

    Memcache 就是一个数据库,将数据保存在内存中 常用于缓存服务器,保存操作频繁,丢失无所谓的数据 启动选项 -d 是一个守护进程 -m 内存分配 -u 用户 -l 监听地址 -p 端口 -c 最 ...