Ed Dablin

Ranch Hand

Posts: 32

Ulf Dittmer

Rancher

Posts: 42972

73

posted 5 years ago

- 1

As some who deals with map data quite a bit, I'd recommend against using doubles. They will cause no end of headaches because of their inaccuracies. Use BigDecimal and your life will be much easier.

posted 5 years ago

I have also read somewhere about the anomaly with double and float. Is there anything bigger (in size ofcourse) that we can utilize for accuracy?

As I understand, it supports 32 bit unscaled integer value while double supports 64 bit. Please correct me if I am wrong.

Bear Bibeault wrote:As some who deals with map data quite a bit, I'd recommend against using doubles. They will cause no end of headaches because of their inaccuracies. Use BigDecimal and your life will be much easier.

I have also read somewhere about the anomaly with double and float. Is there anything bigger (in size ofcourse) that we can utilize for accuracy?

As I understand, it supports 32 bit unscaled integer value while double supports 64 bit. Please correct me if I am wrong.

Never settle for less. Never Quit.

posted 5 years ago

It's not an anomaly. It's a consequence of the design of the IEEE 754 spec, and of the fact that it's impossible to precisely represent every single one of an uncountable infinity of values with a finite number of digits.

As already mentioned, BigDecimal.

Ashish R Garg wrote:

I have also read somewhere about the anomaly with double and float.

It's not an anomaly. It's a consequence of the design of the IEEE 754 spec, and of the fact that it's impossible to precisely represent every single one of an uncountable infinity of values with a finite number of digits.

Is there anything bigger (in size ofcourse) that we can utilize for accuracy?

As already mentioned, BigDecimal.

posted 5 years ago

Although when you're talking about the location of a zip code (as the OP did), then accuracy of doubles isn't really a concern. After all, if you get your latitude accurate to 4 decimal places of a degree, that's the same as to measuring within the nearest 10 metres (if I have the arithmetic right). And accurate to 8 decimal places, that's to within the nearest millimetre. Which would be fine even for engineers building a bridge, I think.

Bear Bibeault wrote:As some who deals with map data quite a bit, I'd recommend against using doubles.

Although when you're talking about the location of a zip code (as the OP did), then accuracy of doubles isn't really a concern. After all, if you get your latitude accurate to 4 decimal places of a degree, that's the same as to measuring within the nearest 10 metres (if I have the arithmetic right). And accurate to 8 decimal places, that's to within the nearest millimetre. Which would be fine even for engineers building a bridge, I think.