Numeric Literals : Data Type « Data Type « Perl






Numeric Literals

   


#!/usr/local/bin/perl



$integerValue = 10;
$floatingPointValue = 11.43;
$scientificValue = 42.03E-04;
$nationalDebt = 6_000_000_000_000;
$divisionValue = 23/7;
$hexValue = 0x0F3;
$octalValue = 037;

$itotal = $integerValue + $hexValue;
$ftotal = $floatingPointValue + $integerValue;
$dtotal = $divisionValue + $octalValue;

print "Integer \t $integerValue\n";
print "Floating Point \t $floatingPointValue\n";
print "Scientific \t $scientificValue\n";
print "National Debt \t $nationalDebt\n";
print "Division \t $divisionValue\n";
print "Hex \t\t $hexValue\n";
print "Octal \t\t $octalValue\n";
print "\n\n";
print "itotal = $itotal\n";
print "ftotal = $ftotal\n";
print "dtotal = $dtotal\n";

   
    
    
  








Related examples in the same category

1.Basic Perl Datatypes
2.Number can be expressed by ###_###_### for ###,###,###
3.Number systems
4.Numeric Literal Formats and Notation
5.Perl 5 Numeric Formats
6.Using Numbers in Scalar Variables