4.7. Long Numbers
Large numbers can be difficult to sanity check: $US_GDP = 10990000000000; $US_govt_revenue = 1782000000000; $US_govt_expenditure = 2156000000000; Those figures are supposed to be in the trillions, but it's very hard to tell if they have the right number of zeros. So Perl provides a convenient mechanism for making large numbers easier to read: you can use underscores to "separate your thousands": Prior to Perl 5.8, these separators could only be placed in front of every third digit of an integer (i.e., to separate the thousands, millions, billions, etc.). From 5.8 onwards, underscores can be placed between any two digits. For example: Separators can also now be used in floating-point numbers and non-decimals, to make them easier to comprehend as well: use bignum; $PI = 3.141592_653589_793238_462643_383279_502884_197169_399375; $subnet_mask= 0xFF_FF_FF_80; |