Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Is the number an Integer or a Float

by cjf-II (Monk)
on Dec 08, 2002 at 00:25 UTC ( [id://218310]=note: print w/replies, xml ) Need Help??


in reply to comparing output to check if is an integer or float

Using Data::Types:

use Data::Types qw/:all/; my @numbers = (0, 3.14, 5); for my $num (@numbers) { if (is_int($num)) { print "$num is an int.\n"; } elsif (is_float($num)) { print "$num is a float.\n"; } else { print "$num is something else.\n"; } }

That should print:

0 is an int. 3.14 is a float. 5 is an int.

More excellent examples in the docs

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-19 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found