thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ephraim Dan <E....@F5.com>
Subject RE: uint64_t
Date Wed, 17 Jun 2009 10:37:30 GMT
Thanks for all the replies.
We will try the casting route.
Just FYI, we are using 64-bit unsigned numbers for a bitmask - we do perform bitwise operations
(& and |) on them, though probably no real arithmetic.
I guess in theory, would bitwise operations work fine even if we don't cast, and treat it
as signed?
Anyway, thanks again for all the info.
--edan

-----Original Message-----
From: Dvir Volk [mailto:dvirsky@gmail.com] 
Sent: Wednesday, June 17, 2009 11:18
To: thrift-user@incubator.apache.org
Subject: Re: uint64_t

to add to that - PHP has horrible handling of ints - it doesn't support
unsinged ints, and their length relies on the OS - ints are 64 bit on 64bit
compiled PHP, and 32 bits on 32bit PHP interpreters.
a real nightmare...

On Wed, Jun 17, 2009 at 1:39 AM, Mark Slee <mslee@facebook.com> wrote:

> Just to quickly address the "why don't we support unsigned ints?" question,
> most of the answers given were correct.
>
> - Unsigned ints are not consistently implemented across languages
>  - In particular, neither Python nor Java, two of the most widely-used
> languages, support them
>  - Hacking in support makes for messy serialization/deserialization code,
> and you run into problems when you are actually using the high bit (i.e.
> does long have to all of a sudden become BigInteger in Java for
> correctness?)
>
> - We noticed in practice that unsigned ints are almost NEVER used for
> arithmetic
>  - They are most commonly used as unique identifiers
>  - Sign is not important for using these as identifiers
>  - If you really want the unsigned value, casting is a viable solution, if
> slightly annoying
>
> My recommendations on this is generally:
>
> 1. Check -- do you actually NEED unsigned integers? Are you doing any
> arithmetic with them?
> 2. If the answer is actually yes, then cast them.
>
> Cheers,
> Mark
>
> -----Original Message-----
> From: Yingbo Miao [mailto:yingbo@thoora.com]
> Sent: Tuesday, June 16, 2009 7:51 AM
> To: thrift-user@incubator.apache.org
> Subject: Re: uint64_t
>
> In C++, you can cast uint64_t to int64_t and cast back. Data won't be
> lost, since both are 64-bits. e.g.
>
>     uint64_t ui = 0xFFFFFFFFFFFFFFFF;
>     cout << "ui=" << ui << endl;    int64_t ii= ui;
>     cout << "ii=" << ii << endl;
>     uint64_t ui2= ii;
>     cout << "ui2=" << ui2 << endl;
>
> and the outputs are:
>     ui=18446744073709551615
>     ii=-1
>     ui2=18446744073709551615
>
>
>
> --Yingbo
>
> On Jun 16, 2009, at 6:36 AM, 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
>
>

Mime
View raw message