473,473 Members | 1,994 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

faq 1.#QNAN00000000 and -1.#IND000000000

Hi,
I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme, what
happened?
why?
Thanks.
Nov 1 '06 #1
12 8300

fcvcnet wrote:
Hi,
I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme, what
happened?
why?
If you can post your code then it might be more easy to find the
problem.

Nov 1 '06 #2
"fcvcnet" <fc*****@163.comwrote in message
news:ei**********@news.cn99.com...
Hi,
I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme, what
happened?
why?
Thanks.
NAN is not a number. This can happen with a floating point math won't work.
In some cases dividing by 0 will produce a NAN, but in others it produces
infinity (not sure if the specs say whiat it should produce).

Not sure what IND is. It may be infinity, but I would think that would be
INF, so I'm not sure.
Nov 1 '06 #3
Jim Langston <ta*******@rocketmail.comwrote:
"fcvcnet" <fc*****@163.comwrote in message
news:ei**********@news.cn99.com...
>Hi,
I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme, what
happened?
why?
Thanks.

NAN is not a number. This can happen with a floating point math won't work.
In some cases dividing by 0 will produce a NAN, but in others it produces
infinity (not sure if the specs say whiat it should produce).

Not sure what IND is. It may be infinity, but I would think that would be
INF, so I'm not sure.
I'm not sure either, but IND might mean "indeterminate". As in,
(informally) 1/0 is infinity but 0/0 is indeterminate.

http://mathworld.wolfram.com/Indeterminate.html

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Nov 1 '06 #4
Geo

fcvcnet wrote:
Hi,
I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme, what
happened?
why?
Thanks.
recently I had to do some experimentation with this stuff, here's some
code and the output
float pinf = std::numeric_limits<float>::infinity();
double dpinf = std::numeric_limits<double>::infinity();

float ninf = -std::numeric_limits<float>::infinity();
float zero = 0.0;
float NaN = std::numeric_limits<float>::quiet_NaN();
float nNaN = -std::numeric_limits<float>::quiet_NaN();
double dNaN = std::numeric_limits<double>::quiet_NaN();

float xNaN = static_cast<float>(dNaN);

std::cout << "+ve infinity " << pinf << "\n";
std::cout << "-ve infinity " << ninf << "\n";
std::cout << "+ve QNAN " << NaN << "\n";
std::cout << "+ve dQNAN " << dNaN << "\n";
std::cout << "+ve xQNAN " << xNaN << "\n";
std::cout << "-ve QNAN " << nNaN << "\n";
std::cout << "+inf = +inf " << (pinf == pinf) << "\n";
std::cout << "+inf <= +inf " << (pinf <= pinf) << "\n";
std::cout << "+inf = +dinf " << (pinf == dpinf) << "\n";
std::cout << "+inf = -inf " << (pinf == ninf) << "\n";
std::cout << "+inf / +inf " << pinf/pinf << "\n";
std::cout << "+inf / -inf " << pinf/ninf << "\n";
std::cout << "+inf / zero " << pinf/zero << "\n";
std::cout << "+inf * -inf " << pinf*ninf << "\n";
std::cout << "+inf + -inf " << pinf+ninf << "\n";
std::cout << "+inf + +inf " << pinf+pinf << "\n";
std::cout << "+inf - -inf " << pinf-ninf << "\n";
std::cout << "+inf - +inf " << pinf-pinf << "\n";
std::cout << "-inf - -inf " << ninf-ninf << "\n";
std::cout << "\n\n";
std::cout << "NaN = NaN " << (NaN == NaN) << "\n";
std::cout << "-NaN = -NaN " << (nNaN == nNaN) << "\n";
std::cout << "-NaN = NaN " << (nNaN == NaN) << "\n";
std::cout << "NaN = -NaN " << (NaN == nNaN) << "\n";
std::cout << "NaN = +inf " << (NaN == pinf) << "\n";
std::cout << "NaN = -inf " << (NaN == ninf) << "\n";
std::cout << "0 / zero " << 0/zero << "\n";

+ve infinity 1.#INF
-ve infinity -1.#INF
+ve QNAN 1.#QNAN
+ve dQNAN 1.#QNAN
+ve xQNAN 1.#QNAN
-ve QNAN -1.#IND
+inf = +inf 1
+inf <= +inf 1
+inf = +dinf 1
+inf = -inf 0
+inf / +inf -1.#IND
+inf / -inf -1.#IND
+inf / zero 1.#INF
+inf * -inf -1.#INF
+inf + -inf -1.#IND
+inf + +inf 1.#INF
+inf - -inf 1.#INF
+inf - +inf -1.#IND
-inf - -inf -1.#IND
NaN = NaN 0
-NaN = -NaN 0
-NaN = NaN 0
NaN = -NaN 0
NaN = +inf 0
NaN = -inf 0
0 / zero -1.#IND

Nov 1 '06 #5
Geo
Meant to say, results are from gcc on pentium, and seem to agree with
IEEE 754. VC 6.0 results differ for some cases, VC 7.0 is the same as
gcc.

Nov 1 '06 #6
Thanks you very much.

"Geo" <gg@remm.org>
??????:11********************@e3g2000cwe.googlegro ups.com...
Meant to say, results are from gcc on pentium, and seem to agree with
IEEE 754. VC 6.0 results differ for some cases, VC 7.0 is the same as
gcc.

Nov 2 '06 #7
Thanks you very much.
"Marcus Kwok" <ri******@gehennom.invalidдÈëÏûÏ¢ÐÂÎÅ:ei********* *@news-int2.gatech.edu...
Jim Langston <ta*******@rocketmail.comwrote:
>"fcvcnet" <fc*****@163.comwrote in message
news:ei**********@news.cn99.com...
>>Hi,
I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme,
what
happened?
why?
Thanks.

NAN is not a number. This can happen with a floating point math won't
work.
In some cases dividing by 0 will produce a NAN, but in others it produces
infinity (not sure if the specs say whiat it should produce).

Not sure what IND is. It may be infinity, but I would think that would
be
INF, so I'm not sure.

I'm not sure either, but IND might mean "indeterminate". As in,
(informally) 1/0 is infinity but 0/0 is indeterminate.

http://mathworld.wolfram.com/Indeterminate.html

--
Marcus Kwok
Replace 'invalid' with 'net' to reply

Nov 2 '06 #8
Thanks you very much.

"Jim Langston" <ta*******@rocketmail.comдÈëÏûÏ¢ÐÂÎÅ:Cz********** ***@newsfe07.lga...
"fcvcnet" <fc*****@163.comwrote in message
news:ei**********@news.cn99.com...
>Hi,
I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme,
what happened?
why?
Thanks.

NAN is not a number. This can happen with a floating point math won't
work. In some cases dividing by 0 will produce a NAN, but in others it
produces infinity (not sure if the specs say whiat it should produce).

Not sure what IND is. It may be infinity, but I would think that would be
INF, so I'm not sure.

Nov 2 '06 #9
Marcus Kwok
Thanks you very much.
your url
http://mathworld.wolfram.com/Indeterminate.html

is very useful!
Thanks again!
Nov 2 '06 #10
cts
Odd that no one seems to have brought up errno.

When something in the C libraries, like the math library, fails, the
global variable errno is set. If you get a value of #QNAN or #IND,
it's likely that an error in the standard math library. You can easily
check this after an operation and you can get a nice string
representation of the error message too.

example:

#include <cmath>
#include <cstring>
#include <iostream>

errno = 0; // clear out any previous errors

// example math call
y = std::atan(x); // we suspect that something screwy happens here,
maybe 'x' is a bad value

// check if there was a catastrophe, if yes, print out the error
message
if (errno)
std::cout << strerror(errno) << std::endl;

fcvcnet wrote:
Hi,
I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme, what
happened?
why?
Thanks.
Nov 2 '06 #11
Thanks you very much.

"cts" <sm*****@gmail.com>
??????:11*********************@f16g2000cwb.googleg roups.com...
Odd that no one seems to have brought up errno.

When something in the C libraries, like the math library, fails, the
global variable errno is set. If you get a value of #QNAN or #IND,
it's likely that an error in the standard math library. You can easily
check this after an operation and you can get a nice string
representation of the error message too.

example:

#include <cmath>
#include <cstring>
#include <iostream>

errno = 0; // clear out any previous errors

// example math call
y = std::atan(x); // we suspect that something screwy happens here,
maybe 'x' is a bad value

// check if there was a catastrophe, if yes, print out the error
message
if (errno)
std::cout << strerror(errno) << std::endl;

fcvcnet wrote:
>Hi,
I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme,
what
happened?
why?
Thanks.

Nov 3 '06 #12
#include "stdafx.h"
#include <cmath>
#include <cstring>
#include <iostream>

int main(int argc, char* argv[])
{
errno = 0;
double i,j;
i=1;
j=0;
double y = i/j;
if (errno)
std::cout << strerror(errno) << std::endl;
std::cin >i;
return 0;
}
I tried , but I saw nothing. My code right?
Nov 3 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Blair | last post by:
could someone PLEASE tell me why this doesn't work... ----------------------------------------- #include <complex> using namespace std; typedef complex<long double> cld; void main() { cld...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.