I need to split a uint
to a list of bits
(list of chars
, where every char is "0"
or "1"
, is also Ok). The way I try to do it is to concatenate the uint
into string
first, using binary representation for numeric types - bin()
, and then to split it using str_split_all()
:
var num : uint(bits:4) = 0xF; // Can be any number
print str_split_all(bin(num), "/w");
("/w"
is string match pattern that means any char).
The output I expect:
"0"
"b"
"1"
"1"
"1"
"1"
But the actual output is:
0. "0b1111"
Why doesn't it work? Thank you for your help.