c++ 判断inf 和nan 的情况

原文链接:https://blog.csdn.net/X_And_Y/article/details/80446084

参考链接:http://en.cppreference.com/w/cpp/numeric/math/isinf

程序中碰到nan却找不到哪里出错是最让人头疼的问题之一,最近在cppreference上找到相关的库函数可以对异常状态进行判断。

判断inf
如果是inf则返回true, 其他情况(包括nan)返回false

bool isinf( float arg );
bool isinf( double arg );
bool isinf( long double arg );
bool isinf( Integral arg );


如果是有限数返回true,其他情况(包括nan)返回false

bool isfinite( float arg );
bool isfinite( double arg );
bool isfinite( long double arg );
bool isfinite( Integral arg );


判断nan

bool isnan( float arg );
bool isnan( double arg );
bool isnan( long double arg );
bool isnan( Integral arg );

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值