Quantcast
Channel: Go4Expert
Viewing all articles
Browse latest Browse all 1997

Ceil/Floor/Round in Perl

$
0
0

Ceil in Perl



Cieling is basically outputing the next largest integer for an given real number.
Code:
ceiling(x) is the smallest integer not less than x
Ways to do it in Perl, a) using our own logic

Code:
my $num = 45.4;
my $ceil = int($num + 0.99);
b) using POSIX

Code:
use POSIX qw/ceil/;

my $num = 45.4;
my $ceil = ceil($num);

Floor in Perl



Flooring is outputing the next smallest integer for an given real number....

Ceil/Floor/Round in Perl

Viewing all articles
Browse latest Browse all 1997

Trending Articles