Tuesday, July 12, 2016

n in binary

(n):
    buffer = new
    do:
        buffer.insert(0, n &1)
        n = n >>> 1 // logical bitshift instead of arithmetic
    while n != 0:
    return buffer.tostring()

No comments:

Post a Comment