C语言温度负数

#include <stdio.h>
#include <stdlib.h>
#include<string.h>
  
int main(int argc,char *argv[])  
{  
	float temp=65519;
	if (((short)temp) & 0x8000) //负数
	{
		printf("负 %f\n", (-1)*((float)((~(short)temp)+1))/10 ); //负 -1.700000
	}
	else
	{
		printf("正 %f", temp / 10);
	}
  return 0;  
}
发布了331 篇原创文章 · 获赞 140 · 访问量 71万+

猜你喜欢

转载自blog.csdn.net/chenhao0568/article/details/103764154