…I have a Grails domain class dealing with geo location data for interacting with google maps:
Float latitude
Float longitude
When the following values get saved to a db :
latitude : 2.5485291419153366, longitude : -76.03939712047577
I end up having : 2.54853;-76.0394 respectively.
What’s the best way of preserving the initial values in this case?
Thanks in advannce
You will probably want to use BigDecimal. Floating point numbers arn’t garanteed to be 100% accurit while you can control the number of digits with BigDecimal. Grails doesn’t offer constraints for this so you’ll have to use methods as setScale to determine the number of digits to store. FOr more info see
http://download.oracle.com/javase/1.5.0/docs/api/java/math/BigDecimal.html