c语言1 qnan,什么是 1.#QNAN?

这篇博客介绍了浮点数中的特殊值QNAN(Quiet Not A Number)、SNaN(Signaling Not A Number)、INF(Infinity)和IND(Indeterminate),这些在数学运算中表示无法定义或不合法的结果。QNAN在运算中自由传播,而SNaN用于触发异常。INF表示无穷大,包括正无穷和负无穷,而IND表示不确定的无限小。了解这些概念对于理解和处理浮点数异常至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

满意答案

dcebd7a0de6265b6ccae5ead692f1eab.png

micktx_fx

推荐于 2017.12.15

dcebd7a0de6265b6ccae5ead692f1eab.png

采纳率:45%    等级:12

已帮助:5322人

此处的1.#QNAN是一个打印呈现,QNAN是指Quiet Not a Number,类似的浮点错误还有SNaN(Signaling Not a Number),通常如0.0/0.0、给负数开平方根等溢出或无效运算就会产生一个NAN结果的表示值,NaN及两种浮点错误的说明如下:

The value NaN (Not a Number) is used to represent a value that does not represent a real number. NaN’s are represented by a bit pattern with an exponent of all 1s and a non-zero fraction. There are two categories of NaN: QNaN (Quiet NaN) and SNaN (Signalling NaN).

A QNaN is a NaN with the most significant fraction bit set. QNaN’s propagate freely through most arithmetic operations. These values pop out of an operation when the result is not mathematically defined.

An SNaN is a NaN with the most significant fraction bit clear. It is used to signal an exception when used in operations. SNaN’s can be handy to assign to uninitialized variables to trap premature usage.

Semantically, QNaN’s denote indeterminate operations, while SNaN’s denote invalid operations. If a return value is a QNaN, it means that it is impossible to determine the result of the operation, a SNaN means that the operation is invalid.

这样的特殊浮点数还有INF和IND:INF就是Infinity,表示一个无穷大的数,包括正无穷和负无穷;IND则表示无限小,但不确定。如1.0/0.0会产生一个INF无穷大,-1.0/0.0会产生一个负无穷大。

参考:http://blog.sina.com.cn/s/blog_4bf793ad0100o28e.html

00分享举报

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值