Add support for 'k', 'M', and 'G' suffixes to integer constants.

(Denoting units of 1024, 1024*1024, and 1024*1024*1024, respectively.)

Issue #128.
This commit is contained in:
Matt Pharr
2012-01-06 14:47:47 -08:00
parent 11033e108e
commit 8da9be1a09
5 changed files with 83 additions and 20 deletions

View File

@@ -1247,6 +1247,18 @@ Here are three ways of specifying the integer value "15":
int fifteen_hex = 0xf;
int fifteen_binary = 0b1111;
A number of suffixes can be provided with integer numeric constants.
First, "u" denotes that the constant is unsigned, and "ll" denotes a 64-bit
integer constant (while "l" denotes a 32-bit integer constant). It is also
possible to denote units of 1024, 1024*1024, or 1024*1024*1024 with the
SI-inspired suffixes "k", "M", and "G" respectively:
::
int two_kb = 2k; // 2048
int two_megs = 2M; // 2 * 1024 * 1024
int one_gig = 1G; // 1024 * 1024 * 1024
Floating-point constants can be specified in one of three ways. First,
they may be a sequence of zero or more digits from 0 to 9, followed by a
period, followed by zero or more digits from 0 to 9. (There must be at