Kirill Grouchnikov
11/05/2021, 8:39 PMephemient
11/05/2021, 9:14 PMULongArray(3) { 0u.inv().toULong() }
is short and less "magical", maybeKirill Grouchnikov
11/05/2021, 9:21 PMephemient
11/05/2021, 9:38 PM~0U
is a very typical way to express that in C, and 0u.inv()
is the analogue in Kotlin, plus .toULong()
because no implicit conversions. but ymmv I guessKirill Grouchnikov
11/05/2021, 9:42 PM0u.inv()
is an unnecessary distraction when you read such codeKirill Grouchnikov
11/05/2021, 9:43 PMephemient
11/05/2021, 9:47 PMmcpiroman
11/06/2021, 6:32 AMDominaezzz
11/06/2021, 12:02 PM0b000000000000000000000000000000011111111111111111111111111111111u
is more readable tbh. 🧌Phani Mahesh
11/23/2021, 8:50 AM0xFF_FF_FF_FFu
? 😛ephemient
11/23/2021, 10:34 AM>>> StringBuilder("0b000000000000000000000000000000011111111111111111111111111111111u").apply { var c = 0; for (i in 3..64) insert(i + c, String(CharArray(Random.nextInt(4).also { c += it }) { '_' })) }.toString()
res0: kotlin.String = 0b00__0___0___0___0___0_0_0___0__00_0_00___000_0___00_0___00___0___00___0_0__0___011_11_1___1__1_11_1__1___1___1_1_1_1111__1_1_1__1___1_11__1_11_1___1__1u
>>> 0b00__0___0___0___0___0_0_0___0__00_0_00___000_0___00_0___00___0___00___0_0__0___011_11_1___1__1_11_1__1___1___1_1_1_1111__1_1_1__1___1_11__1_11_1___1__1u == 0xffffffffu
res1: Boolean = true
TIL: Kotlin allows for any size groupings separated by any number of underscores