1. #include <iostream>
    2. using namespace std;
    3. int main() {
    4. // 1、单精度 float
    5. // 2.双精度 double
    6. // 默认情况下 输出一个小数,会显示出6位有效数字
    7. float f1 = 3.1415926f;
    8. cout << "f1 = " << f1 << endl;
    9. double d1 = 3.1415926;
    10. cout << "d1 = " << d1 << endl;
    11. // 统计float(4)、double(8)所在内存空间大小
    12. cout << "float内存大小" << sizeof(f1) << endl;
    13. cout << "double内存大小" << sizeof(d1) << endl;
    14. // 科学计数法
    15. float f2 = 3e2; // 3 * 10 ^ 2
    16. cout << "f2 = " << f2 << endl;
    17. system("pause");
    18. return 0;
    19. }