大一C
#include<stdio.h>void main()
{
unsigned char a = 100, b = 200, c;
c = a + b;
printf("a=%d,b=%d,a+b=%d\n", a, b, c);
printf("a=%d,b=%d,a+b=%d\n", a, b, a + b);
{
float a;
double b;
a = (float)1 / 3;
b = (double)1 / 3;
printf("a=%.8f,b=%.17f\n", a, b);
}
}
为什么两次输出a+b的值不同啊? 本帖最后由 baige 于 2020-10-28 19:04 编辑
unsigned char范围:(0~255)用c保存溢出后就相当于对256取余
300%256 = 44
页:
[1]