通过本文主要向大家介绍了c++浮点数,c++输出浮点数,c++结构体定义,c++宏定义,c++数组定义等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
在实际计算中可能会出现浮点型的无效数据,格式化输出到文件中内容为1.79769e+308,输出到界面就是很大一串数据。这两种方式无论哪种在阅读和查找时就不是很方便。
无效值定义如下:#define InvalidDouble *(double*)("\xff\xff\xff\xff\xff\xff\xef\x7f")
double price;
.........(计算步骤省掉)
price=GetPrice(); //获取数据
通过下面方式对浮点型的数据进行判定
(price==InvalidDouble)?0:price
</div>
无效值定义如下:#define InvalidDouble *(double*)("\xff\xff\xff\xff\xff\xff\xef\x7f")
double price;
.........(计算步骤省掉)
price=GetPrice(); //获取数据
通过下面方式对浮点型的数据进行判定
(price==InvalidDouble)?0:price
</div>