-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(c) fixed hex decimal numbers (#4094)
- Loading branch information
Showing
4 changed files
with
101 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<span class="hljs-comment">/* Floating-point literals. */</span> | ||
<span class="hljs-comment">// Decimal.</span> | ||
<span class="hljs-number">1.</span> | ||
+<span class="hljs-number">12.</span> | ||
<span class="hljs-number">1.2</span> | ||
<span class="hljs-number">1234e56</span> | ||
|
||
<span class="hljs-comment">// Hexadecimal.</span> | ||
<span class="hljs-number">0x1p2</span> | ||
+<span class="hljs-number">0x1.p2</span> | ||
<span class="hljs-number">-0X1A.P2</span> | ||
<span class="hljs-number">0x1.Ap2</span> | ||
|
||
<span class="hljs-comment">// Literal suffixes.</span> | ||
<span class="hljs-number">1.F</span> | ||
|
||
<span class="hljs-comment">/* Integer literals. */</span> | ||
<span class="hljs-comment">// Binary.</span> | ||
+<span class="hljs-number">0b1</span> <span class="hljs-comment">// Note: Not standard C, but valid in some compilers</span> | ||
<span class="hljs-number">0B</span>01 <span class="hljs-comment">// Note: Not standard C, but valid in some compilers</span> | ||
|
||
<span class="hljs-comment">// Hexadecimal.</span> | ||
+<span class="hljs-number">0x1</span> | ||
<span class="hljs-number">0X1A</span> | ||
|
||
<span class="hljs-comment">// Octal.</span> | ||
+<span class="hljs-number">01</span> | ||
<span class="hljs-number">012</span> | ||
|
||
<span class="hljs-comment">// Decimal.</span> | ||
<span class="hljs-number">0</span> | ||
+<span class="hljs-number">1</span> | ||
<span class="hljs-number">12</span> | ||
|
||
<span class="hljs-comment">// Literal suffixes.</span> | ||
<span class="hljs-number">0X2L</span> | ||
<span class="hljs-number">0x2l</span> | ||
<span class="hljs-number">03LL</span> | ||
<span class="hljs-number">03ll</span> | ||
<span class="hljs-number">4UL</span> <span class="hljs-number">4Ul</span> <span class="hljs-number">4uL</span> <span class="hljs-number">4ul</span> | ||
<span class="hljs-number">5LU</span> <span class="hljs-number">5Lu</span> <span class="hljs-number">5lU</span> <span class="hljs-number">5lu</span> | ||
<span class="hljs-number">6ULL</span> <span class="hljs-number">6Ull</span> <span class="hljs-number">6uLL</span> <span class="hljs-number">6ull</span> | ||
<span class="hljs-number">7LLU</span> <span class="hljs-number">7LLu</span> <span class="hljs-number">7llU</span> <span class="hljs-number">7llu</span> | ||
|
||
<span class="hljs-comment">// Character array.</span> | ||
<span class="hljs-type">char</span> word[] = { <span class="hljs-string">'3'</span>, <span class="hljs-string">'\0'</span> }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* Floating-point literals. */ | ||
// Decimal. | ||
1. | ||
+12. | ||
1.2 | ||
1234e56 | ||
|
||
// Hexadecimal. | ||
0x1p2 | ||
+0x1.p2 | ||
-0X1A.P2 | ||
0x1.Ap2 | ||
|
||
// Literal suffixes. | ||
1.F | ||
|
||
/* Integer literals. */ | ||
// Binary. | ||
+0b1 // Note: Not standard C, but valid in some compilers | ||
0B01 // Note: Not standard C, but valid in some compilers | ||
|
||
// Hexadecimal. | ||
+0x1 | ||
0X1A | ||
|
||
// Octal. | ||
+01 | ||
012 | ||
|
||
// Decimal. | ||
0 | ||
+1 | ||
12 | ||
|
||
// Literal suffixes. | ||
0X2L | ||
0x2l | ||
03LL | ||
03ll | ||
4UL 4Ul 4uL 4ul | ||
5LU 5Lu 5lU 5lu | ||
6ULL 6Ull 6uLL 6ull | ||
7LLU 7LLu 7llU 7llu | ||
|
||
// Character array. | ||
char word[] = { '3', '\0' }; |