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_ ...
随机推荐
- Python跳过第一行读取文件内容
Python编程时,经常需要跳过第一行读取文件内容.比较容易想到是为每行设置一个line_num,然后判断line_num是否为1,如果不等于1,则进行读取操作.相应的Python代码如下: inpu ...
- Domion OA 日记
我现在使用的是IBM的 Lotus Dimion 8.5 以下内容是个人的浅显了解,在此记录下,已作为后续记录的翻看 第一次接触文档型数据库,确实颠覆了我对数据模型的认知,我之前一直用sql的 文档型 ...
- Asp.net上传文件Request.files获取不到文件
使用ftp上传文件,并且Request.files获取文件,今天发现获取到的文件个数始终是0个,查了下原来form标签中需加入enctype=”multipart/form-data”,呵呵了 < ...
- Python学习(9)列表
目录 Python 列表 访问列表中的值 更新列表 删除列表元素 列表脚本操作符 列表截取 列表函数&方法 Python 列表(List) 序列是Python中最基本的数据结构.序列中的每个元 ...
- Java中的数学运算BigDecimal
Math类 package ch7; /** * Created by Jiqing on 2016/11/24. */ public class MathDemo { public static v ...
- C++——对象和类
最重要的OOP特性: *抽象: *封装和数据隐藏: *多态: *继承: *代码的可重用性: 一.抽象和类 1.类型 指定基本类型完成了三项工作:1).决定数据对象需要的内存数量:2).决定如何解释内存 ...
- The Zen Programmer (zhuan)
http://blog.csdn.NET/marksinoberg/article/details/52460725 ***************************************** ...
- kvm相关文章
配置KVM虚拟机的网络 Bridge和Nat方式http://www.it165.net/os/html/201503/12231.html KVM虚拟机网络配置 Bridge方式,NAT方式 htt ...
- UAT 环境
User Accept Environment 用户仿真测试环境
- RemoteWebDriver管理
直接贴代码: @Parameters({"BrowserType","NodeIP","NodePort"}) public void be ...