Skip to content

Commit 08f74ca

Browse files
committed
Add reference page
1 parent 1574490 commit 08f74ca

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
layout: doc-page
3+
title: "Binary Integer Literals"
4+
nightlyOf: https://docs.scala-lang.org/scala3/reference/changed-features/binary-integer-literals.html
5+
---
6+
7+
A new syntax for integer literals has been added, it is now possible to do the following:
8+
```scala
9+
val bitmask = 0b0010_0000 // equivalent to 32, 0x20
10+
```
11+
12+
Binary integer literals behave similarly to hex integer literals (`0x...`), for example:
13+
* Both `0b...` and `0B...` are allowed
14+
* `0b`/`0B` on its own is disallowed, possible alternatives: `0`, `0b0`, `0B0`
15+
* Only `0` and `1` are allowed after the b (`b`/`B`)
16+
* Underscores `_` are allowed anywhere after the b, and are ignored: `0b__1__ == 0b1`
17+
18+
19+
Note: This change has been backported to Scala 2.13.13, it is therefore not technically a changed feature

0 commit comments

Comments
 (0)