什么是1.#INF00,-1。#IND00和-1。#IND是什么意思? [英] What do 1.#INF00, -1.#IND00 and -1.#IND mean?

查看:604
本文介绍了什么是1.#INF00,-1。#IND00和-1。#IND是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用花车与一些C code乱搞,我越来越1.#INF00,-1。#IND00和-1。#IND当我尝试在屏幕打印浮动。什么是这些价值观是什么意思?我相信,1#INF00手段正无穷大,但对于-1。#IND00和-1。#IND?我也看到了这有时值:1. $ NaN的这不是一个数字,但什么原因导致这些奇怪的价值观,这些如何能帮助我调试

I'm messing around with some C code using floats and I'm getting 1.#INF00, -1.#IND00 and -1.#IND when I try to print floats in the screen. What does those values mean? I believe that 1.#INF00 means positive infinity, but what about -1.#IND00 and -1.#IND? I also saw sometimes this value: 1.$NaN which is Not a Number but what causes those strange values and how can those help me with debugging?

我使用MingW平台,我相信使用IEEE 754重新presentation浮法点。

I'm using MingW which I believe uses IEEE 754 representation for float points.

有人能列出所有这些无效的价值观和他们是什么意思?

Can someone list all those invalid values and what they mean?

推荐答案

这是用C IEEE浮点异常++

这个页面将回答以下问题。

This page will answer the following questions.


      
  • 我的程序刚刚打印出来,1#IND或1#INF(在Windows)或男或INF(在Linux上)。发生了什么事?

  •   
  • 我如何知道一个数量更是一个数字,而不是一个NaN或无穷大?

  •   
  • 我如何才能找到在运行时更多细节种的NaN和无穷大?

  •   
  • 你有什么样code,以显示这是如何工作?

  •   
  • 我在哪里可以学到更多?

  •   

这些问题与浮点异常的事情。如果你在那里你期望一个数字一些奇怪的非数字输出,你要么超出了浮点运算的有限限制或您问过一些结果是不确定的。为了简单起见,我会坚持与双浮点类型的工作。类似的言论持有浮法类型。

These questions have to do with floating point exceptions. If you get some strange non-numeric output where you're expecting a number, you've either exceeded the finite limits of floating point arithmetic or you've asked for some result that is undefined. To keep things simple, I'll stick to working with the double floating point type. Similar remarks hold for float types.

调试1#IND,1#INF,NaN和INF

如果您的操作将产生比可存储在一个双更大的正数,该操作将在Windows或INF返回Linux上的1#INF。同样的code将返回-1。#INF或-INF如果结果是负数太大,无法在一个双存储。除以零的正数产生一个正无穷大和除以一个负数由零产生负无穷大。在这个页面的最后例如code将证明,产生无穷的一些操作。

If your operation would generate a larger positive number than could be stored in a double, the operation will return 1.#INF on Windows or inf on Linux. Similarly your code will return -1.#INF or -inf if the result would be a negative number too large to store in a double. Dividing a positive number by zero produces a positive infinity and dividing a negative number by zero produces a negative infinity. Example code at the end of this page will demonstrate some operations that produce infinities.

的某些操作不作数学意义,如采取负数的平方根。 (是,这个操作是有意义的在复数的上下文中,但双重presents一个实数,所以不存在双重重新present的结果。)也是如此为负数的对数。双方的sqrt(-1.0)和日志(-1.0)将返回一个NaN时,对于数字,即非数字的通称。 Windows会显示为NaN为-1。#IND(IND为不确定),而Linux的显示男。这将返回NaN的其他操作包括0/0,0 *∞,有∞/∞。见下面的例子样品code。

Some operations don't make mathematical sense, such as taking the square root of a negative number. (Yes, this operation makes sense in the context of complex numbers, but a double represents a real number and so there is no double to represent the result.) The same is true for logarithms of negative numbers. Both sqrt(-1.0) and log(-1.0) would return a NaN, the generic term for a "number" that is "not a number". Windows displays a NaN as -1.#IND ("IND" for "indeterminate") while Linux displays nan. Other operations that would return a NaN include 0/0, 0*∞, and ∞/∞. See the sample code below for examples.

总之,如果你得到1#INF或INF,寻找溢出或除以零。如果你得到1#IND或楠,寻找违规操作。也许你只是有一个bug。如果是更微妙的,你有东西是难以计算,见避免溢出,下溢和precision的损失。这篇文章给出了窍门,如果计算直接计算具有中间步骤的溢出效果。

In short, if you get 1.#INF or inf, look for overflow or division by zero. If you get 1.#IND or nan, look for illegal operations. Maybe you simply have a bug. If it's more subtle and you have something that is difficult to compute, see Avoiding Overflow, Underflow, and Loss of Precision. That article gives tricks for computing results that have intermediate steps overflow if computed directly.

这篇关于什么是1.#INF00,-1。#IND00和-1。#IND是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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