c语言隐式转换规则

不同类型数据计算时,自动类型转换

1、小字节类型向大字节类型转换

2、有符号类型向无符号类型转换(符合第一个原则,有符号类型的最高为符号位。)

3、整数向实数型转换

#include<stdio.h>
int main(){
	double num;	
//	double temp=0.0;
	scanf("%lf",&num);
	int temp=ceil(num);
	printf("ceil=%d\n",temp);
	int temp1=floor(num);
	printf("floor=%d\n",temp1);
	int temp2=round(num);
	printf("round=%d\n",temp2);
	return 0; 
} 

结果为

hehe

猜你喜欢

转载自blog.csdn.net/ithongchou/article/details/82983047