Quantcast
Channel: Convert int to binary string in Python - Stack Overflow
Viewing all articles
Browse latest Browse all 74

Answer by Galle He for Python int to binary string?

$
0
0

I found a method using matrix operation to convert decimal to binary.

import numpy as npE_mat = np.tile(E,[1,M])M_order = pow(2,(M-1-np.array(range(M)))).Tbindata = np.remainder(np.floor(E_mat /M_order).astype(np.int),2)

Eis input decimal data,M is the binary orders. bindata is output binary data, which is in a format of 1 by M binary matrix.


Viewing all articles
Browse latest Browse all 74

Trending Articles