double int char 数据类型
贴心的limits...
测试代码:
#include <iostream>
#include <stdio.h>
#include <limits>
#include <math.h>
using namespace std; int main() {
//double 有效数字16位
double test3 = 1.2345678912345678e17;
printf("%.17lf\n", test3); test3 = 1.23456789123456789123e17;
printf("%.17lf\n", test3); int a = (int)pow(2, 32);
cout << "int 2^32: " << a << "===\n"; int b = (int)pow(2, 64);
cout << "long long to int: " << b << "===\n"; long long c = (long long)pow(2, 64);
cout << "long long 2^64: " << c << "===\n"; cout << "type\t---" << "+++++++++++++++size+++++++++++++++\n";
cout << "bool\t---" << "size:" << sizeof(bool) << "\tmax:" << (numeric_limits<bool>::max()) << "\t\tmin:" << numeric_limits<bool>::min() << endl;
cout << "int\t---" << "size:" << sizeof(int) << "\tmax:" << (numeric_limits<int>::max()) << "\t\tmin:" << numeric_limits<int>::min() << endl;
cout << "long long---" << "size:" << sizeof(long long) << "\tmax:" << (numeric_limits<long long>::max()) << "\t\tmin:" << numeric_limits<long long>::min() << endl;
cout << "double\t---" << "size:" << sizeof(double) << "\tmax:" << (numeric_limits<double>::max()) << "\t\tmin:" << numeric_limits<double>::min() << endl;
cout << "long\t---" << "size:" << sizeof(long) << "\tmax:" << (numeric_limits<long>::max()) << "\t\tmin:" << numeric_limits<long>::min() << endl;
}
运行:

其中:关于double
double就是IEEE754的64位浮点数
1位符号位
11位指数位
52位尾数位
即 精确到52位2进制位。
也就是说,精确到log(2^52)/log(10) = 15.6535597 位10进制位。
然后,float和double的精度是由尾数的位数来决定的。浮点数在内存中是按科学计数法来存储的,其整数部分始终是一个隐含着的“1”,
由于它是不变的,故不能对精度造成影响。
所以,有效数字是15-16位,没有精确到小数点后几位之说。【大概是?T_T】
然后附偷来的详细一点的:

double int char 数据类型的更多相关文章
- double int char long 等数据类型所占的字节数-----待整理
- Linux基本数据类型大小——int,char,long int,long long int
转自:http://paddy-w.iteye.com/blog/1403217 在Linux操作系统下使用GCC进行编程,目前一般的处理器为32位字宽,下面是/usr/include/limit.h ...
- JAVA实体类不要使用基本类型,基本类型包含byte、int、short、long、float、double、char、boolean
由于JAVA的基本类型会有默认值,例如当某个类中存在private int age;字段时,创建这个类时,age会有默认值0.当使用age属性时,它总会有值.因此在某些情况下,便无法实现age为nu ...
- C 语言实例 - 计算 int, float, double 和 char 字节大小
C 语言实例 - 计算 int, float, double 和 char 字节大小 C 语言实例 C 语言实例 使用 sizeof 操作符计算int, float, double 和 char四种变 ...
- Cstring转char、string、int等数据类型的方法(转载)
Cstring转char.string.int等数据类型的方法 (-- ::) 转载 标签: 杂谈 分类: VC CString 转char * CString cstr; char *p = (LP ...
- python 调用C++ DLL,传递int,char,char*,数组和多维数组
ctypes 数据类型和 C数据类型 对照表 ctypes type C type Python type c_bool _Bool bool (1) c_char char 1-character ...
- Integer 类和 int 基本数据类型的区别
public static void main(String[] args) { Integer i = 10; Integer j = 10; System.out.println(i == j); ...
- C语言下double转char*或者std::string,可以精确转换不含多余的0
char* GetDoubleStr(double value) { char buf[32]={0};//长度可以自定义 sprintf(buf,"%.8f",value);// ...
- 将日期或数据转换为char数据类型 TO_CHAR(x[[,c2],C3])
TO_CHAR(x[[,c2],C3])[功能]将日期或数据转换为char数据类型[参数]x是一个date或number数据类型.c2为格式参数c3为NLS设置参数如果x为日期nlsparm=NLS_ ...
随机推荐
- eclipse svn 忽略 target目录 等等... 我用的后边的方法 (转载)
这个build失败的解决方案就是不要把你项目的 target目录放在src repository 里面,还有 .project 和 .classpath 最好也别放到src repository 里. ...
- RARP
ARP的工作原理如下:1. 首先,每台主机都会在自己的ARP缓冲区 (ARP Cache)中建立一个 ARP列表,以表示IP地址和MAC地址的对应关系.2. 当源主机需要将一个数据包要发送到目的主机时 ...
- iOS - Swift Subscript 下标脚本
1.Subscript 下标脚本允许你通过在实例后面的方括号中传入一个或者多个的索引值来对实例进行访问和赋值.语法类似于实例方法和计算型属性的混合.与定义实例方法类似,定义下标脚本使用 subscri ...
- iOS - Swift NSNumber 数字
前言 public class NSNumber : NSValue public class NSDecimalNumber : NSNumber NSNumber 可以被赋值为各种数值类型.我们可 ...
- 从POI到O2O 看百度地图如何走出未来之路
近期O2O的烧钱融资大战如火如荼,有人已经把O2O大战,用乌合之众的群体心理失控来形容.其实厂商都不傻,O2O烧钱大家都知道,但是大家还知道O2O背后这块大蛋糕价值"万亿级". 有 ...
- [转载] TLS协议分析 与 现代加密通信协议设计
https://blog.helong.info/blog/2015/09/06/tls-protocol-analysis-and-crypto-protocol-design/?from=time ...
- 12 Using_explain_plan
The row source tree is the core of the execution plan. The tree shows the following information: An ...
- linux查看文件夹大小
du -sh 查看当前文件夹大小 du -sh * | sort -n 统计当前文件夹(目录)/文件的大小,并按文件大小排序 ------------------------------------- ...
- linux runlevel
Linux系统有7个运行级别(runlevel)运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动运行级别1:单用户工作状态,root权限,用于系统维护,禁止远程登陆运行级别2:多 ...
- s3c2440 J-flash 烧写 NOR flash
视屏教程里是在NOR Flash 烧写了一个supervivi然后通过superViVi配合DNW下载Uboot程序到landflash第零块,由于我电脑室64位win7,官方提供的USB下载驱动不能 ...