int() Function:
The int() function returns the integer part of a number.
Example :
#! C:programfilesperlbinperl
print "content-type: text/htmlnn";
$int1 = int(40.12);
$int2 = int(60.13);
print "Integer part of 40.12 is : $int1n";
print "<br>";
print "Integer part of 60.13 is : $int2n";
Result :
Integer part of 40.12 is : 40
Integer part of 60.13 is : 60
rand() Function:
The rand() function is used to retrieve the next pseudo random number.
Example :
#! C:programfilesperlbinperl
print "content-type: text/htmlnn";
$rand1 = rand();
print "Get any random number:", $rand1 ,"n";
print "<br>";
$rand2 = rand(100);
print "Get random number till 100:", $rand2 ,"n";
Result :
Get any random number:0.18963623046875
Get random number till 100:62.127685546875
sqrt() Function:
The sqrt() function is used to return the square root value for a number.
Example :
#! C:programfilesperlbinperl
print "content-type: text/htmlnn";
$sqr = sqrt(4);
print "The Square root of 4 is:: $sqrn";
Result :
The Square root of 4 is:: 2
srand() Function:
The srand() function seed the random number generator.
Example :
#! C:programfilesperlbinperl
print "content-type: text/htmlnn";
$rand1 = srand();
print "Get any random number:", $rand1 ,"n";
Result :
Get any random number:1
abs() Function:
The abs() function is used to get the absolute value for a numeric value, returns zero if a string is passed as argument.
Example :
#! C:programfilesperlbinperl
print "content-type: text/htmlnn";
$abs1 = abs(11.22);
$abs2 = abs("VBN");
$abs3 = abs(10);
$abs4 = abs(-10);
print "$abs1 <br>";
print "$abs2 <br>";
print "$abs3 <br>";
print "$abs4 <br>";
Result :
11.22
0
10
10
exp() Function:
The exp() function returns the exponential value of "e" to the power of the argument taken by the function.
Example :
#! C:programfilesperlbinperl
print "content-type: text/htmlnn";
$ret_val = exp(1);
print "Exponetial of 1 is: $ret_valn";
Result :
Exponetial of 1 is: 2.71828182845905