I have the follow array:
val cells = arrayOf(
0b1, 0b1, 0b1,
0b0, 0b0, 0b0,
0b0, 0b0, 0b0,
)
And I want to convert it to number e.g: 0b111000000
, to be able to compare with another byte after:
val cells = arrayOf(
0b1, 0b1, 0b1,
0b0, 0b0, 0b0,
0b0, 0b0, 0b0,
)
print(arrayOfBitsToByte(cells) == 0b111000000)
I could make this:
val cells = arrayOf(
0b1, 0b1, 0b1,
0b0, 0b0, 0b0,
0b1, 0b1, 0b1,
)
print(cells.joinToString("") == 0b111000000.toString(2))
But in the above case, the 2 values were cast to String
And I would like to know if it is possible to compare the numbers without cast to string