Question

Is the use of Double (boxed type) highly recommended over the use of Long (boxed type) in GWT. I've read many official resources (I think all of them) but I couldn't realize how harmful is to use Long objects instead of Double ones. I'm heavily concerned about performance but if the cost does not make big difference, I would stay with Longs.

Was it helpful?

Solution

AFAIK, both, long and Long are implemented in GWT as an Array of two numbers (containing the low and high half of the long). The reason is that the integer precision of Javascript numbers is limited to 53 bit, but a Long contains 64 bit. All mathematical operations are turned into complex multi-number array operations, which is quite expensive.

That said, it really depends on what you do with the Longs: If you just use them as IDs or similar, and long operations are not one of the main bottlenecks of your program, it may just be fine to stick to Longs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top