generating infinit doubles

M

MrPugh

Hi!

I need to initialize a double with infinity (inf or 1.#INF). Now in
Windows you can do that by simply assigning it this way:

double x = numeric_limits<double>::infinity();

The problem is: on Unix-systems, that will return 0.0 .

Is there another way creating infinity besides division by zero (x =
1.0 / 0.0 would return the desired value, but not without a
warning...)?

Thanks in advance for the help.

Ruben
 
R

Ron Natalie

Victor Bazarov said:
(a) This is the _standard_ way to get 'x' to be infinity.

And plenty of UNIX systems have infinity and do the right
thing. The fact that MrPugh's implementation doesn't isn't
a reflection on UNIX overall.
 
V

Victor Bazarov

Ron Natalie said:
And plenty of UNIX systems have infinity and do the right
thing. The fact that MrPugh's implementation doesn't isn't
a reflection on UNIX overall.

I didn't contest MrPugh's statement because I don't know UNIX
that well (although the generalisation didn't sound OK, to be
entirely honest). I'll trust your word on that.
 
R

Ron Natalie

Victor Bazarov said:
I didn't contest MrPugh's statement because I don't know UNIX
that well (although the generalisation didn't sound OK, to be
entirely honest). I'll trust your word on that.
Of course, the other thing is that infinity() is returning the correct value
and his printf or whatever he's using to check it can't deal with it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top