long double 使用方法

时间:2025-02-14 08:03:37
long double 使用方法

qq_41441842: 不管什么编译器long double都是8字节 [code=csharp] #define _CRT_SECURE_NO_WARNINGS #include <> int main(){ // sizeof 操作符用于计算变量的字节大小 printf("Size of char: %ld byte\n", sizeof(char)); printf("Size of unsigned char: %ld bytes\n\n", sizeof(unsigned char)); printf("Size of short: %ld bytes\n", sizeof(short)); printf("Size of signed short: %ld bytes\n\n", sizeof(signed short)); printf("Size of int: %ld bytes\n", sizeof(int)); printf("Size of float: %ld bytes\n", sizeof(float)); printf("Size of unsigned int: %ld bytes\n", sizeof(unsigned int)); printf("Size of long: %ld bytes\n", sizeof(long)); printf("Size of signed long: %ld bytes\n\n", sizeof(unsigned long)); printf("Size of double: %ld bytes\n", sizeof(double)); printf("Size of long double: %ld bytes\n", sizeof(long double)); return 0; } //发现不论是32位编译器还是64位编译器这些类型所占字节数就没有变过!!!! //Size of char: 1 byte //Size of unsigned char : 1 bytes // //Size of short : 2 bytes //Size of signed s [/code]