This is what I have, currently. Is there any nicer way to do this?
import struct
def int32_to_uint32(i):
return struct.unpack_from("I", struct.pack("i", i))[0]
This is what I have, currently. Is there any nicer way to do this?
import struct
def int32_to_uint32(i):
return struct.unpack_from("I", struct.pack("i", i))[0]
Not sure if it's "nicer" or not...
import ctypes
def int32_to_uint32(i):
return ctypes.c_uint32(i).value
using numpy for example:
import numpy
result = numpy.uint32( numpy.int32(myval) )
or even on arrays,
arr = numpy.array(range(10))
result = numpy.uint32( numpy.int32(arr) )