[omniORB] How to convert long integer in python to unsigned long in CORBA

Piet van Oostrum piet at cs.uu.nl
Fri Oct 28 12:43:25 BST 2005


>>>>> Vito Bica <vitob5 at cox.net> (VB) wrote:

>VB> I have defined the following value in python:
>VB> x = 0x80000000

>VB> Python seems to interpret this as an unsigned value, and therefore makes it
>VB> a long integer (2147483648, one more than the maximum positive value
>VB> allowable for a signed 32 bit int).

>VB> I try to pass it as a value in a CORBA method that takes an argument of
>VB> CORBA type "Unsigned Long". Python balks, saying that it cannot convert the
>VB> python Long Integer type to an integer. What I really want is to get that
>VB> value passed as-is as an argument to that CORBA method. Is there anything I
>VB> can do in Python or with some omnipy fucntion that will map that 32 bit
>VB> value into the CORBA unsigned long argument?

maxint1 = 2147483648
if x>=maxint1: x-=2*maxint1

(You can't use sys.maxint on a non-32bit machine)
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the omniORB-list mailing list