日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

double int char 数据类型

發布時間:2023/11/27 生活经验 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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】

?

然后附偷來的詳細一點的:

轉載于:https://www.cnblogs.com/icode-girl/p/5371383.html

總結

以上是生活随笔為你收集整理的double int char 数据类型的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。