tags:

views:

187

answers:

2

Possible Duplicate:
How do I create or test for NaN or infinity in Perl?

How can I check, if scalar holds inf value?

I check NaN as $scalar != $scalar, what to do with inf?

$scalar == inf does not work, since inf is a bareword

A: 

I found a dirty hack right now.

($scalar eq "inf")

Does anything cleaner exist?

Karel Bílek
Not good. Perl will stringify inf however the underlying libc does, and that can vary (both within the C standard and, on Windows, far outside it).
ysth
A: 

you can use this to check for infinity:

$scalar < 9**9**9

that constant is so large that it will be interpreted as infinite by Perl

Eric Strom