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;  
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章