About why, I think you're right.

About solutions - casting is obviously easier - you don't think it could mess 
up the sign bit in the translation?  i.e. you think that solution is 64-bit 
safe?

Thanks for the reply,
--edan

-----Original Message-----
From: Jonathan Marcus [mailto:[email protected]] 
Sent: Tuesday, June 16, 2009 16:29
To: [email protected]
Subject: Re: uint64_t

I'm pretty sure that Thrift doesn't support it because unsigned numbers 
aren't supported in all the languages (I could be wrong).

Nonetheless, I can think of two workarounds:

     - Cast your number to a 64-bit signed long before transport, then 
re-cast it as an unsigned long on the other side.

     - Use two int fields to send it, storing the first 32 bits in one 
and the second 32 bits in the other.
function prepareForTransport(ulong val) {
        int valA = val & 0xFFFFFFFF;
        int valB = (val >> 32) & 0xFFFFFFFF;
        return array(valA, valB)
}

function decompressFromTransport(int valA, int valB) {
        return valA + ((ulong) valB << 32);
}

Not a pretty solution, but it should work just fine.

--Jonathan

Ephraim Dan wrote:
> We have some big numbers, that we use "unsigned long long" (uint64_t) for in 
> our code.
> Thrift apparently explicitly doesn't support unsigned integer types.
> What are we to do if we do, after all, need to transport such a number using 
> thrift?
> 
> Thanks
> --edan
> 

Reply via email to