检查浮点变量是否具有“正常"值 [英] check if floating point variable has 'normal' values

查看:58
本文介绍了检查浮点变量是否具有“正常"值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何检查浮点值是否为正数并且没有任何粗略状态(+ -inf,ind,nan,qnan,denormal ...).

how can i check if a floating point value is a normal number and does not have any crude states (+-inf, ind, nan, qnan, denormal ...).

用self来检查身份似乎对nan有用,但是其他州呢?

Checking for identity with it self seems to work for nan, but the other states?

对不起-我忘了提及我与C90编译器绑定的原因;(

Sorry - i forgot to mention that I am tied to an C90 Compiler ;(

推荐答案

您可以使用isnormal宏:

#include <math.h>
int isnormal(real-floating x);

还有isfiniteisinfisnan宏.

这篇关于检查浮点变量是否具有“正常"值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆