|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How would you go about determining if a number is an integer or a float?
|
|
#2
|
|||
|
|||
|
$number = 1.2334;
if($number =~ /\./) { print "This is a floating point number."; } else { print "This is a integer."; } |
|
#3
|
|||
|
|||
|
gareth, the only problem with that is that it will fail with a number like 3.0 which you might want interpreted as an integer.
i would suggest using this code Code:
my $num = 3.1254;
if($num - int($num)) { print "is float"; }
else { print "is integer"; }
|
|
#4
|
|||
|
|||
|
Awesome
![]() Thanks a bunch! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Determining Ints |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|