Programming Perl

Programming PerlSearch this book
Previous: 3.2.75 indexChapter 3
Functions
Next: 3.2.77 ioctl
 

3.2.76 int

int EXPR

This function returns the integer portion of EXPR. If EXPR is omitted, it uses $_. If you're a C programmer, you'll often forget to use int in conjunction with division, which is a floating-point operation in Perl:

$average_age = 939/16;      # yields 58.6875 (58 in C)
$average_age = int 939/16;  # yields 58


Previous: 3.2.75 indexProgramming PerlNext: 3.2.77 ioctl
3.2.75 indexBook Index3.2.77 ioctl