The hex function in Perl converts the given hexadecimal number ( of base 16 ) into its equivalent decimal number ( of base 10 ).
Syntax: hex number
Parameters:
number: hexadecimal number to be converted
Returns: equivalent decimal number of the given hexadecimal number.
Example 1:
$A = "A" ;
$B = "B" ;
$C = "1A" ;
$D = "2C" ;
$E = hex $A ;
$F = hex $B ;
$G = hex $C ;
$H = hex $D ;
print "$E\n" ;
print "$F\n" ;
print "$G\n" ;
print "$H\n" ;
|
Output:
10
11
26
44
Example 2:
$A = hex D;
$B = hex af;
$C = hex AF;
$D = hex BF;
print "$A\n" ;
print "$B\n" ;
print "$C\n" ;
print "$D\n" ;
|
Output :
13
175
175
191
Last Updated :
07 May, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...