Files
learn_cpp/实型数据类型.cpp
2026-02-24 07:39:30 +08:00

22 lines
554 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// Created by viole on 2026/2/24.
//
#include "iostream"
#include "windows.h"
using namespace std;
int main() {
SetConsoleOutputCP(CP_UTF8);
//float 单精度浮点数4字节6-7位的有效位数
float num1 = 1234567890;
float num2 = 1.234567890;
double num3 = 1234567890.1234567890;
long double num4 = 1234567890.1234567890;
cout<<fixed;
cout.width(20);
cout<<num1<<endl;
cout<<num2<<endl;
cout<<sizeof(num2)<<endl;
cout<<num3<<","<<sizeof(num3)<<endl;
cout<<num4<<","<<sizeof(num4)<<endl;
}