Darren Smith wrote:
> Hi,
>
> Thanks. Okay, now I understand the motivation. Yep, JSON protocol does not
> have an unsigned number type.
>
> The problem I have is that I'm using jansson to communicate between two
> applications. The sender has a size_t value (unsigned long long), and wants to
> send that to the receiver (and the receiver is expected a size_t) This can be
> done, but, it has to be squeezed through a double: size_t --> double --
> jansson -- double --> size_t
If you squeeze the 64-bit integer through a double, you only get 53
bits of precision and lose the 11 least signifigant bits. That's less
than when using Jansson's json_int_t (signed long long), where you get
63 bits of precision.
And actually, you get the full 64 bits if you accept the fact that
numbers >= 2^63 are just encoded as negative values in the JSON
representation. When casting to size_t (or unsinged long long), you
get the original positive value back.
Petri