生活消费
emby server 隐藏目录 infuse emby目录错误
2024-12-31 14:17

20.5.2 Infinity and NaN

IEEE 754 floating point numbers can represent positive or negative infinity, and NaN (not a number). These three values arise from calculations whose result is undefined or cannot be represented accurately. You can also deliberately set a floating-point variable to any of them, which is sometimes useful. Some examples of calculations that produce infinity or NaN:

When a calculation produces any of these values, an exception also occurs; see FP Exceptions.

The basic operations and math functions all accept infinity and NaN and produce sensible output. Infinities propagate through calculations as one would expect: for example, 2 + ∞ = ∞, 4/∞ = 0, atan (∞) = π/2. NaN, on the other hand, infects any calculation that involves it. Unless the calculation would produce the same result no matter what real value replaced NaN, the result is NaN.

In comparison operations, positive infinity is larger than all values except itself and NaN, and negative infinity is smaller than all values except itself and NaN. NaN is unordered: it is not equal to, greater than, or less than anything, including itself. is false if the value of is NaN. You can use this to test whether a value is NaN or not, but the recommended way to test for NaN is with the function (see Floating Point Classes). In addition, , , , and will raise an exception when applied to NaNs.

math.hdefines macros that allow you to explicitly set a variable to infinity or NaN.

Macro: float INFINITY

An expression representing positive infinity. It is equal to the value produced by mathematical operations like . represents negative infinity.

You can test whether a floating-point value is infinite by comparing it to this macro. However, this is not recommended; you should use the macro instead. See Floating Point Classes.

This macro was introduced in the ISO C99 standard.

Macro: float NAN

An expression representing a value which is “not a number”. This macro is a GNU extension, available only on machines that support the “not a number” value—that is to say, on all machines that support IEEE floating point.

You can use ‘#ifdef NAN’ to test whether the machine supports NaN. (Of course, you must arrange for GNU extensions to be visible, such as by defining , and then you must includemath.h.)

IEEE 754 also allows for another unusual value: negative zero. This value is produced when you divide a positive number by negative infinity, or when a negative result is smaller than the limits of representation.

 

 

inf :infinity (linux)  等同于   #INF:infinity  (windows)

nan :not a number     等同于      #IND:indeterminate (windows)

注意:1、inf一般是因为得到的数值,超出浮点数的表示范围(溢出,即阶码部分超过其能表示的最大值);而nan一般是因为对浮点数进行了未定义的操作,如对-1开方。

      2、nan==nan 结果是0或false,即不能和nan进行比较,和nan进行比较得到的结果总是false或0。所以可以用函数:   int isNumber(double d){return (d==d);}来判断d是否为nan,若d是nan则返回0,否则返回非零值。

      3、1.0/0.0等于inf,-1.0/0.0等于-inf,0.0+inf=inf;

      4、对负数开方sqrt(-1.0)、对负数求对数(log(-1.0))、0.0/0.0、0.0*inf、inf/inf、inf-inf这些操作都会得到nan。(0/0会产生操作异常;0.0/0.0不会产生操作异常,而是会得到nan)

      5、得到inf时就查看是否有溢出或者除以0,得到nan时就查看是否有非法操作。

      6、C语言的头文件<float.h>中,有定义的常量DBL_MAX,这个常量表示“能表示出来的最大的双精度浮点型数 值”。<float.h>中还有常量DBL_MIN,DBL_MIN表示可以用规格化表示的最小的正浮点数,但DBL_MIN并不是最小的正 浮点数,因为可以用可以用非规格化浮点数表示的更小。可以用函数:int isFiniteNumber(double d){return (d<=DBL_MAX&&d>=-DBL_MAX);}来判断d是否为一个finite数(既不是inf,又不是 nan(加入d为nan,则d参加比较就会得到false(0)值))。

      7、1.0/inf等于0.0。

      8、inf是可以与其他浮点数进行比较的,即可以参与<=、>+、==、!=等运算。

 

下面这几个宏(用宏实现的,使用时跟函数的形式基本相同)是判断一个表达式的结果是否为inf、nan或其他:

     头文件:include<math.h>

     宏的用法(类似于函数原型):int fpclassify(x);

                                 int isfinite(x);

                                 int isnormal(x);

                                 int isnan(x);

                                 int isinf(x);

     具体用法:

          1、int fpclassify(x)  用来查看浮点数x的情况,fpclassify可以用任何浮点数表达式作为参数,fpclassify的返回值有以下几种情况。

                  FP_NAN:x是一个“not a number”。

                  FP_INFINITE: x是正、负无穷。

                  FP_ZERO: x是0。

                  FP_SUBNORMAL: x太小,以至于不能用浮点数的规格化形式表示。

                  FP_NORMAL: x是一个正常的浮点数(不是以上结果中的任何一种)。

          2、int isfinite(x)  当(fpclassify(x)!=FP_NAN&&fpclassify(x)!=FP_INFINITE)时,此宏得到一个非零值。

          3、int isnormal(x)  当(fpclassify(x)==FP_NORMAL)时,此宏得到一个非零值。

          4、int isnan(x)   当(fpclassify(x)==FP_NAN)时,此宏返回一个非零值。

          5、int isinf(x)   当x是正无穷是返回1,当x是负无穷时返回-1。(有些较早的编译器版本中,无论是正无穷还是负无穷,都返回非零值,不区分正负无穷)。


    以上就是本篇文章【emby server 隐藏目录 infuse emby目录错误】的全部内容了,欢迎阅览 ! 文章地址:http://ww.kub2b.com/news/17005.html
     栏目首页      相关文章      动态      同类文章      热门文章      网站地图      返回首页 企库往资讯移动站 http://ww.kub2b.com/mobile/ , 查看更多   
最新文章
京东万商 v6.2.2手机京东app下载「京东万商 v6.2.2」
uses-permission:'android.permission.INTERNET',允许程序访问网络连接,可能产生GPRS流量uses-permission:'android.permission.
三星Galaxy S8多少钱?三星Galaxy S8价格s8手机「三星Galaxy S8多少钱?三星Galaxy S8价格」
三星Galaxy S8多少钱  三星Galaxy S8的价格预计约6000元。   三星Galaxy S8基于Android7.0深度定制的UI,在主界面通过上下滑
如何设置路虎屏幕投屏?路虎手机「如何设置路虎屏幕投屏?」
要将手机屏幕内容投射到路虎车内的中控屏,有两种主要的方法,一种适用于安卓设备,一种适用于iPhone设备。首先,对于安卓设备,
林峯老婆张馨月再惹争议!用60元山寨手机壳被扒,删帖逃避引群嘲
娱乐圈从来不缺热闹,尤其是那些站在镁光灯边缘的“家属们”。最近,林峯的老婆张馨月(Carina)可谓是“热搜钉子户”,从检查离
百万新娘之爱无悔宝莲乘敏君沏茶的时候用她的手机给天祥发短信手机短信发不出去是什么原因「百万新娘之爱无悔宝莲乘敏君沏茶的时候用她的手机给天祥发短信」
很高兴和大家见面啦,我是小轮娱乐君,请多多指教。宝莲称敏君沏茶的时候,赶紧用她的手机给天祥发了短信,之后又装作有急事的样
小米手机怎么检测硬件,小米手机硬件检测教程
买了小米手机后,很多人会关心配置是否优越或存在不足。接下来,我将分享如何检测小米手机硬件的教程,帮助你了解设备性能与状况
京基智农2024年净利下滑59%
新京报讯(记者王思炀)4月1日,新京报记者了解到,日前召开2024年业绩说明会。2024年,京基智农实现营业收入59.60亿元,同比下
DNF:至尊天空价格&外观汇总!蝴蝶套最贵,墨染丹清最值得拿下
我们都知道自从DNF推出12套普通天空后,就不再推出了!虽说普通天空不再推出,但是至尊天空却一直在推出着。从第一套至尊天空若
两个android手机通过蓝牙连接手机蓝牙连接「两个android手机通过蓝牙连接」
在现代社会中,蓝牙已经成为了一种常见的无线通信技术。通过蓝牙,我们可以实现多种设备之间的连接和数据传输,比如手机与耳机、
炉石盒子工具版炉石传说盒子手机版「炉石盒子工具版」
炉石盒子工具版是一款非常好用的游戏辅助类应用,提供了很多的游戏资讯让用户可以第一时间掌握,而且还提供了最新的新手教学视频