Determining the Type of Literal Constants
-
Integer constants are of type int, unless they are too large, in which case they are type long int
-
Floating point constants are of type double
-
You can change these defaults with modifiers
Literal | Type |
3 | int (signed int) |
3L | long int |
3U | unsigned int |
3.0 | double |
3.0F | float |
3.0L | long double |
-
Integer constants are base 10 by default; 2, 63, 83
-
A constant starting with a 0 is octal (base 8); 02, 077, 0123
-
A constant starting with a 0x is hexadecimal (base 16); 0x2, 0x3f, 0x53
Next page
Go to Lesson 4 index.