c++常见变量的极值
#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++常见变量的极值的更多相关文章
- Makefile 隐含规则,模式规则,常见变量
隐含规则复杂的Makefile一般会使用隐含规则内的变量来简化编译处理.将隐含规则中使用的变量分成两种:一种是命令相关的,如“CC”:一种是参数相关的,如“CFLAGS”.这些变量都是大写表示. 常 ...
- 跟厂长学PHP7内核(七):常见变量类型的基本结构
上篇文章讲述了变量的存储结构zval,今天我们就来学习一下几个常见变量类型的基本结构. 一.类型一览 zval中的u1.v.type用来存储变量的类型,而zval.value存储的是不同类型对应的值, ...
- PHP7内核(七):常见变量类型的基本结构
上篇文章讲述了变量的存储结构zval,今天我们就来学习一下几个常见变量类型的基本结构. 一.类型一览 zval中的u1.v.type用来存储变量的类型,而zval.value存储的是不同类型对应的值, ...
- makefile常用指令和常见变量。
引用文章A:http://blog.csdn.net/liang13664759/article/details/1771246 文章介绍:非常详细的文章,讲解上都是比较基础的知识. 本文可能会持续更 ...
- javascript总结4:javascript常见变量
1 javascript变量 定义:变量在计算机中,是用于存储信息的"容器". 2 使用方法: 2-1 定义变量: var n1; 2-2 变量赋值: var n2=23.45; ...
- 【windows】常见的系统环境变量,如%appdata%表示什么意思
原文:[windows]常见的系统环境变量,如%appdata%表示什么意思 1.介绍 %appdata%就代表了C:Users\用户名\AppData\Roaming这个文件夹. “%”是系统变量的 ...
- shell的变量以及常见符号
shell的变量以及常见符号 常见变量 不同于其它语言需要先声明变量,shell的变量直接使用 eg: a=15 调用变量的话 $a 或者 ${a} $? #判断上一条命令执行的是否成功 0 ...
- shell学习笔记1: shell 中的变量与常见符号使用方法
变量 声明即用 a=2 b="123" 调用 ${varName}或者 $varName echo $b echo ${a} 常见变量 $?:判断上一个语句是否成功 $0:执行脚本 ...
- 5.Powershell变量
在指令执行过程中,会有一些数据产生,这些数据被用于以后的语句,需要一个存储单元暂时的存放这些数据,这个时候定义一个变量来存储数据.例如$string = “Hello Powershell!” Pow ...
随机推荐
- R-shiny服务器安装及配置
R的shiny 服务器管理-入门http://www.bio-info-trainee.com/1683.html sudo systemctl start shiny-serversudo syst ...
- 2018-2019-2 网络对抗技术 20165308 Exp2 后门原理与实践
2018-2019-2 网络对抗技术 20165308 Exp2 后门原理与实践 1.实验内容 (3.5分) (1)使用netcat获取主机操作Shell,cron启动 (0.5分) (2)使用soc ...
- mysql 8.0 主从复制的优化
mysql 8.0复制改进一简介: 基于GTID下的并行复制,本文不考虑MGR架构二 主要特性 1 基于writeset的下的改进型并行复制 我在之前的一篇文章关于并行复制中详细的介绍了关 ...
- React native采坑路 Running 1 of 1 custom shell scripts
1. Running 1 of 1 custom shell scripts 卡住的问题. 分析: 四个文件没有下载完成. boost_1_63_0.tar.gz folly-2016.09.26.0 ...
- 迅速的说清楚rpc原理
第一个问题是服务提供者进程如果被kill -9暴力杀死,不能主动调用srem命令怎么办? 这个时候服务列表中多了一个黑地址指向了不存在的服务而消费者完全不知道,这个时候服务中介就成了黑中介了.那该怎么 ...
- WinHTTrack Website Copier使用说明
WinHTTrack Website Copier使用说明 WinHTTrack Website Copier可以抓取整个网站或者某个网页.某个论坛帖子.以抓取论坛某个主题帖子为例: 1.打开WinH ...
- apache 2.2 和 2.4 访问控制区别 (require 替代 deny)
apache 2.4权限配置 Order命令已从Apache 2.4中删除 注意:使用require指令时,需要在指令外添加<RequireAll></RequireAll>标 ...
- PAT 乙级 1044 火星数字 (20 分)
1044 火星数字 (20 分) 火星人是以 13 进制计数的: 地球人的 0 被火星人称为 tret. 地球人数字 1 到 12 的火星文分别为:jan, feb, mar, apr, may, j ...
- leetcode 890. 查找和替换模式 Python
用模式的每个字母去当做key对应单词列表的每个字母value, 如果放进dict之前检测到key已经存在,就检测Word[i][j]是否是和已经存在的value一致,不一致就代表不匹配,break检查 ...
- Java spring实现文件下载
一,实现目的,后台写一个controller,然后前台页面点击文件下载,实现文件下载功能.(文件是存放于服务器的磁盘上的) @RequestMapping("/filesdownloads& ...