In C language, %x prints integers in lowercase hexadecimal form, and %X prints integers in uppercase hexadecimal form.
The difference between %x and %X
In C language, %x and %X are both formats ization placeholder for printing integers in hexadecimal form. The main difference between them is case.
%x
- Print the integer in lowercase hexadecimal form.
- The resulting value always contains lowercase letters.
- For positive integers, the 0x prefix is not automatically appended.
- For negative integers, a 0x prefix is automatically appended, followed by the negative's complement.
%X
- Print the integer in uppercase hexadecimal form.
- The resulting value always contains uppercase letters.
- For positive integers, the 0X prefix is automatically appended.
- For negative integers, a 0X prefix is automatically appended, followed by the negative's complement.
Sample code:
<code class="c">int i = 100;
printf("小写十六进制:%x\n", i); // 输出:64
printf("大写十六进制:%X\n", i); // 输出:64</code>
Copy after login
Summary:
- %x in lower case hexadecimal The form prints an integer.
- %X Prints an integer in uppercase hexadecimal form.
The above is the detailed content of The difference between %x and %x in C language. For more information, please follow other related articles on the PHP Chinese website!