c语言 ld long double,C语言,数据类型

#include

void f0(void)

{

printf("in linux:

");

printf("sizeof(char) = %d

", sizeof(char));

printf("sizeof(int) = %d

", sizeof(int));

printf("sizeof(short int) = %d

", sizeof(short int));

printf("sizeof(long int) = %d

", sizeof(long int));

printf("sizeof(float) = %d

", sizeof(float));

printf("sizeof(double) = %d

", sizeof(double));

printf("sizeof(long double) = %d

", sizeof(long double));

}

void f1(void)

{

int i = 1;

unsigned int ui = 1;

char c = 1;

unsigned char uc = 1;

short int si = 1;

unsigned short int usi = 1;

float f = 1;

double d = 1;

long double ld = 1;

printf("for 1, i = %x, ui = %x

", i, ui);

printf("for 1, c = %x, uc = %x

", c, uc);

printf("for 1, si = %x, usi = %x

", si, usi);

printf("for 1, f = %x

", f);

printf("for 1, d = %x

", d);

printf("for 1, ld = %x

", ld);

}

void f2()

{

int i = -1;

unsigned int ui = -1;

char c = -1;

unsigned char uc = -1;

short int si = -1;

unsigned short int usi = -1;

float f = -1;

double d = -1;

long double ld = -1;

printf("for -1, i = %x, ui = %x

", i, ui);

printf("for -1, c = %x, uc = %x

", c, uc);

printf("for -1, si = %x, usi = %x

", si, usi);

printf("for -1, f = %x

", f);

printf("for -1, d = %x

", d);

printf("for -1, ld = %x

", ld);

c = -255;

uc = -255;

printf("for -255, c = %x, uc = %x

", c, uc);

c = -128;

uc = -128;

printf("for -128, c = %x, uc = %x

", c, uc);

}

void f_show1(void)

{

printf("for -1,f_show1: uint = %x

", (unsigned int)-1);

printf("for -1,f_show1: int = %x

", (int)-1);

printf("for -1,f_show1: c = %x

", (char)-1);

printf("for -1,f_show1: uc = %x

", (unsigned char)-1);

printf("for -1,f_show1: uc = %d

", (unsigned char)-1);

}

int main()

{

f0();

f_show1();

f1();

f2();

return 0;

}

/*

root@oucaijun:/work/dcc# gcc 1.c ;./a.out

in linux:

sizeof(char) = 1

sizeof(int) = 4

sizeof(short int) = 2

sizeof(long int) = 4

sizeof(float) = 4

sizeof(double) = 8

sizeof(long double) = 12

//此处说明在linux系统中,对整数常数是以?方式表示

for -1,f_show1: uint = ffffffff

for -1,f_show1: int = ffffffff

for -1,f_show1: c = ffffffff

for -1,f_show1: uc = ff

for -1,f_show1: uc = 255

for 1, i = 1, ui = 1

for 1, c = 1, uc = 1

for 1, si = 1, usi = 1

for 1, f = 0

for 1, d = 0

for 1, ld = 0

for -1, i = ffffffff, ui = ffffffff

for -1, c = ffffffff, uc = ff

for -1, si = ffffffff, usi = ffff

for -1, f = 0

for -1, d = 0

for -1, ld = 0

for -255, c = 1, uc = 1

for -128, c = ffffff80, uc = 80

*/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值