Copyright © tutorialspoint.com

PERL int Function


Syntax

int EXPR

int


Definition and Usage

Returns the integer element of EXPR, or $_ if omitted. The int function does not do rounding. If you need to round a value up to an integer, you should use sprintf.

Return Value

  • Integer part of EXPR.

Example

Try out following example:

#!/usr/bin/perl

$int_val = int( 6.23930 );
print"Integer value is $int_val\n";

$int_val = int( -6.23930 );
print"Integer value is $int_val\n";

$int_val = int( 10 / 3 );
print"Integer value is $int_val\n";


It produces following result

Integer value is 6
Integer value is -6
Integer value is 3



Copyright © tutorialspoint.com