Jun 22, 2008

How to use Ciel and Floor Functions

#!F:\Perl\bin\perl -w
use strict;

use POSIX; #ciel and floor available in POSIX module

$a = ceil(3.45);
print "\n $a"; #gives o/p as '4'

$b = floor(3.45);
print "\n $b"; #gives o/p as '3'

printf("\n%.3f", 3.1415926535); #gives output as 3.142, rounds of to 3 digits
#For Rounding use printf and sprintf

No comments:

Post a Comment