php出现NaN,【整理】PHP中的NaN是什么意思

【背景】

折腾:

期间,看到有个NaN,没见过,要去搞懂含义。

【折腾过程】

1.搜:

PHP NaN

PHP NaN含义

what is php nan

参考:

“is_nan — 判断是否为合法数值”

还是没懂NaN是啥含义。

看到评论中的解释:nan/"not a number" is not meant to see if the data type is numeric/textual/etc..

NaN is actually a set of values which can be stored in floating-point variables, but dont actually evaluate to a proper floating point number.

The floating point system has three sections: 1 bit for the sign (+/-), an 8 bit exponent, and a 23 bit fractional part.

There are rules governing which combinations of values can be placed into each section, and some values are reserved for numbers such as infinity. This leads to certain combinations being invalid, or in other words, not a number.

【总结】

貌似就是:

NaN==Not a Number的首字母缩写,含义是:合法数值。

其中这些合法数值,主要是哪些,可以用浮点数去表示(但是未必一定是对应着某个具体的浮点数值)。

注:

JS中也有个类似的函数:isNaN

并且:“isNaN() 函数通常用于检测 parseFloat() 和 parseInt() 的结果,以判断它们表示的是否是合法的数字。当然也可以用 isNaN() 函数来检测算数错误,比如用 0 作除数的情况。”

暂时没搞懂:

为何PHP中会有个is_nan,本意是用来干啥的,主要在何种情况下使用。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值