Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Checking whether a $var is a number

by hsmyers (Canon)
on Sep 06, 2001 at 02:03 UTC ( [id://110433]=note: print w/replies, xml ) Need Help??


in reply to Checking whether a $var is a number

The canonical answer to IsNan is found here: http://www.cpan.org/doc/FMTEYEWTK/is_numeric.html

To Quote:

The special IEEE notions of Infinity and NaN (not a number) will be pr +operly honored: $n = 'NaN'; print 2 * $n; NaN print 10 * $n NaN print 1 + NaN NaN $i = 'Infinity' print 1 + $i Infinity print $i * $i Infinity print $i - $i NaN print 'Infinity' < 0 0 print 'Infinity' > 0 1

hsm

Edit by tye to change very wide BLOCKQUOTE+PRE to CODE

Replies are listed 'Best First'.
Re: Re: Checking whether a $var is a number
by blakem (Monsignor) on Sep 06, 2001 at 02:21 UTC
    Interesting, it looks like this works, but they return 'inf' and 'nan' instead of the longer capitalized versions above.
    % perl -le "print 1 + 'NaN'" nan % perl -le "print 1 + 'Infinity'" inf

    -Blake

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://110433]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-03-29 16:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found