Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

FIOC HELP

Name: Anonymous 2011-02-26 18:19

Is there any way to convert a binary string to a bignum integer directly? For example "abcde" to 418262508645

Of course this can be done by summing the ord() of each character and shifting by 8 in each step. But that's obnoxious. I just want it to interpret the binary data directly as a number.

Name: Anonymous 2011-02-26 20:14

def f(x): return sum((ord(c)<<y*8) for y,c in enumerate(reversed(x)))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List