D
devnew
hi
i am relatively new to python..was checking out some bit shifting..
when i do
255<< 24 i get 4278190080
whereas in java or c it gives -16777216
can someone tell me why this is ?,what should i do if i want the
output as -16777216 ?
dn
p:s
I wrote a fn to show the binary digits in the number and it gives same
output for both numbers(4278190080 and -16777216)
def pBinInt(str,i):
print str,",int",i,", binary:"
print " ",
for j in range(31,-1,-1):
if(((1 << j) & i) != 0):
print 1,
else:
print 0,
print ""
#example usage pBinInt("255",255)
i am relatively new to python..was checking out some bit shifting..
when i do
255<< 24 i get 4278190080
whereas in java or c it gives -16777216
can someone tell me why this is ?,what should i do if i want the
output as -16777216 ?
dn
p:s
I wrote a fn to show the binary digits in the number and it gives same
output for both numbers(4278190080 and -16777216)
def pBinInt(str,i):
print str,",int",i,", binary:"
print " ",
for j in range(31,-1,-1):
if(((1 << j) & i) != 0):
print 1,
else:
print 0,
print ""
#example usage pBinInt("255",255)