Jump to content

Perl Programming/Keywords/int

From Wikibooks, open books for an open world
Previous: INIT Keywords Next: ioctl

The int keyword

[edit | edit source]

int returns the integer part of EXPRESSION or, if EXPRESSION is not specified, that of $_.

This function is inappropriate for rounding, as it truncates towards 0, and the machine-representation of floating-point numbers could return non-intuitive results.

Syntax

[edit | edit source]
  int EXPRESSION
  int

Examples

[edit | edit source]
The print
  print int(842/169) . ', ' . int(1721/169)
4, 10


Previous: INIT Keywords Next: ioctl