1. Perl
  2. builtin functions
  3. here

floor function - round down the fractional part

To round down the decimal point, use the POSIX module's floor function .

use POSIX 'floor';
my $ret = floor $num;

Example

This is an example to round down the decimal point.

use strict;
use warnings;
use POSIX 'floor';

my $num1 = 1.5;
my $num2 = -1.5;

print "(2) Round down the decimal point.\n";
my $num1_floor = floor $num1;
my $num2_floor = floor $num2;

print "Devaluation of $num1: $num1_floor\n";
print "Devaluation of $num2: $num2_floor\n";

Related Informatrion