1. Integer
Int A = 10; decimal, formatted output: % I
Int B = 0743;, formatted output: % o % # O (output leading symbol 0)
Int c = 0x7f3d; hexadecimal format, formatted output: % x % # X (output leading symbol 0x)
2. Floating Point
Float F = 1.234; formatted output: % F (the default length of the fractional part is 6. If it is not enough, fill it with 0)
Double D = 1.3e-11 formatted output: % E (output by science and technology)
In obj-C, the compiler treats Single-precision floating-point numbers as double-precision. Unless defined as float F = 1.23f, it is a single-precision floating-point number.
Formatted output: % g, which is omitted to the excess 0 of the floating point number.
4. Long
Long int A = 10l; formatted output: % Li % lo % lx, which are output in decimal, octal, and hexadecimal formats respectively.
Long long int B = 10ll; formatted output: % llI % llo % LLX, Which is output in decimal, octal, and hexadecimal formats respectively.
Long Double D = 1.234e + 7l; formatted output: % lf % Le % LG
5. unsigned
Unsigned int A = 10u, B = 11u;
Unsigned long int A = 19ul, B = 119ul;
When the value of an int is too large to be stored in the int, And the suffix is not used, the compiler treats it as an unsigned integer.
When the value of an int is too small to be stored in the unsigned int without a suffix, the compiler treats it as a long Int.
Basic Data Types
Type | constant examples | nslog chars
Char | 'A', '\ n' | % C
Short int |-| % Hi, % HX, % Ho
Unsigned short int |-| % Hu, % HX, % Ho
Int | 12,-97, 0xffe0, 0177 | % I, % x, % O
Unsigned int | 12u, 100u, 0 xffu | % u, % x, % O
Long int | 12l,-2001, 0 xffffl | % Li, % lx, % Lo
Unsigned long int | 12ul, 100ul, 0 xffeeul | % lu, % lx, % Lo
Long long int | 0xe5e5e5e5ll, 500ll | % llI, % LLX, & llo
Unsigned long int | 12ull, 0 xffeeull | % LlU, % LLX, % llo
Float | 12.34f, 3.1e-5f, | % F, % E, % G, %
| 0x1. 5p10, 0x1p-1 |
Double | 12.34, 3.1e-5, 0x. 1p3 | % F, % E, % G, %
Long double | 12.341, 3.1e-5l | % lf, % Le, % LG
Id | nil | % P