File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -6,21 +6,25 @@ Pluto makes two small changes to numeral parsing.
6
6
## Cosmetic Underscores
7
7
8
8
You can add underscores to your numeric literals to make them more readable.
9
- ``` pluto showLineNumbers title="Example Code"
9
+ ``` pluto
10
10
local n = 10_000_000
11
- assert(n == 10000000)
11
+ print(n) --> 10000000
12
12
```
13
13
These underscores are ignored by the compiler, so they are purely cosmetic.
14
14
15
- ## Binary Integers
15
+ ## Binary & Octal Numerals
16
16
17
17
Similar to how Lua allows you to input numbers in hexadecimal:
18
- ``` pluto showLineNumbers title="Example Code"
19
- local n = 0x420
20
- assert(n == 1056)
18
+ ``` pluto
19
+ local n = 0x2A
20
+ print(n) --> 42
21
21
```
22
- Pluto allows you to input numbers in binary as well:
23
- ``` pluto showLineNumbers title="Example Code"
24
- local n = 0b1000101
25
- assert(n == 69)
22
+ Pluto allows you to input numbers in binary and octal as well:
23
+ ``` pluto
24
+ local n = 0b101010
25
+ print(n) --> 42
26
+ ```
27
+ ``` pluto
28
+ local n = 0o52
29
+ print(n) --> 42
26
30
```
Original file line number Diff line number Diff line change 580
580
"match" : " 0[bB][01][01_]*" ,
581
581
"name" : " constant.numeric.integer.binary.pluto"
582
582
},
583
+ {
584
+ "match" : " 0[oO][0-7][0-7_]*" ,
585
+ "name" : " constant.numeric.integer.octal.pluto"
586
+ },
583
587
{
584
588
"match" : " (?<![\\ w\\ d])\\ d[0-9_]*(?![pPeE.0-9])" ,
585
589
"name" : " constant.numeric.integer.pluto"
You can’t perform that action at this time.
0 commit comments