>>>>> ""Rodrick" == "Rodrick Brown" <[EMAIL PROTECTED]> writes:
"Rodrick> #!/usr/bin/perl
"Rodrick> my $p = 10;
"Rodrick> if( int($p) ) {
"Rodrick> print "$p is an interger\n";
"Rodrick> }
"Rodrick> ~
Not even close.
$ perldoc -f int
int EXPR
int Returns the integer portion of EXPR. If EXPR is omitted, uses
$_. You should not use this function for rounding: one because
it truncates towards 0, and two because machine representations
of floating point numbers can sometimes produce counterintuitive
results. For example, "int(-6.725/0.025)" produces -268 rather
than the correct -269; that's because it's really more like
-268.99999999999994315658 instead. Usually, the "sprintf",
"printf", or the "POSIX::floor" and "POSIX::ceil" functions will
serve you better than will int().
Since you're using that in a boolean context, any number that
isn't from -0.9999 to 0.99999 will report true... like "123.45".
See the other *CORRECT* answers in this thread.
And you might want to note that submitting a *bad* answer to the beginners
mailing list is worse than submitting *no* answer, because it means that the
resources of People With More Experience Than You now have to correct you
instead of providing a nice answer for the real question. Please
hesitate before posting next time. Thanks.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/