I have noticed with testing GPS locations, a value such as −123 might come up on Android as −23.83333336. Is there any way to format incoming GPS locations, such as within two decimal points?
This way I can store values like −123.83 opposed to longer numeric values. I have checked out DecimalFormat and NumberFormat, but these are strings and my numbers are doubles, and I cannot find a better way.
And does anyone know a maximum value of a location in numeric values? Knowing that, I can do something like
DecimalFormat df = new DecimalFormat("####.##");
knowing the highest number is in the thousands, etc.
A function like this will round it without converting to a string:
For instance
roundDouble(502.23525, 2)will produce 502.24