How do I get IEEE infinity?

S

Steve Chapel

Denver said:
It mathematics, division by 0 is undefined, not infinity (infinity is
not large enough).

Yes, I understand that 1/0 is undefined in the real numbers.

However, in IEEE arithmetic, there is +0.0 which represents both 0 and
positive numbers that are too small to be represented with any
precision. in IEEE floating point, +1.0/+0.0 is +infinity. In most
programming environments, 1.0/0.0 is +infinity. That's what I would have
expected in Perl.
 
S

Steve Chapel

Steve said:
I want to use the IEEE floating point value +Infinity in Perl.

Sorry to open this can of worms again, but now I find that it would be
convenient in my Perl program to have a floating point number that
represents NaN (not a number), which is used to represent the result of
expressions such as 0/0 and sqrt(-1). Math::BigFloat has a way to
represent NaN, but is there a way to do it in native Perl?
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
Steve Chapel
Sorry to open this can of worms again, but now I find that it would be
convenient in my Perl program to have a floating point number that
represents NaN (not a number), which is used to represent the result of
expressions such as 0/0 and sqrt(-1). Math::BigFloat has a way to
represent NaN, but is there a way to do it in native Perl?

Proceed as adviced before:

~->perl -wle "print exp 1e1000000"
Infinity
~->perl -wle "print sin exp 1e1000000"
NaN

Hope this helps,
Ilya
 

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

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top