a casual look saw a _lot_ of bits in a double

so i thought ' how many 7 bit ascii chars could be encoded'?

allowing short messages to be sent

like this:

# encode 9 chars into 64bit container
str="WakeuNnow"
n= 0
for c in str:
    n = n | (ord(c) & 0x7f)
    n = n << 7

print(bin(n))
0b1010111110000111010111100101101010111100001001110110111111101110000000
nsav = n

# get the 9 chars back
n = nsav
l = len(str)
for byt in range(l+1):
    c=n&0x7f
    cl[l-byt] = chr(c)
    n=n>>7

# display the chars retrieved
cl
['W', 'a', 'k', 'e', 'U', 'p', 'N', 'o', 'w', '\x00']


just for s&g

tomp



_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to