Perl sqrt Function


Advertisements


Description

This function returns the square root of EXPR, or $_ if omitted. Most of the time, this function returns a floating point number.

Syntax

Following is the simple syntax for this function −

sqrt EXPR

sqrt

Return Value

This function returns the Floating point number.

Example

Following is the example code showing its basic usage −

#!/usr/bin/perl -w

$result = sqrt(4);
print " sqrt(4) is $result\n";

When above code is executed, it produces the following result −

sqrt(4) is 2


Advertisements