Decimal to binary as double type array, not string

后端 未结 3 812
半阙折子戏
半阙折子戏 2020-12-07 03:15

I have this so far:

data = 14
out = dec2bin(data, 4)

which gives:

out = 1110

But I want to get binary num

3条回答
  •  日久生厌
    2020-12-07 04:02

    Yet another way: Use "bitget":

    data = 14
    out = bitget (data, 4:-1:1)
    out =
       1   1   1   0
    

提交回复
热议问题