I have the following method which takes in GPS coordinates as strings and converts them to doubles with a maximum of 6 decimal points. Now I'm trying to randomize the decimal points starting from the first decimal.
public void randomizeCoordinate(String latString, String lonString)
{
double lat = Double.parseDouble(latString);
double lon = Double.parseDouble(lonString);
DecimalFormat df = new DecimalFormat("#.######");
df.setRoundingMode(RoundingMode.HALF_EVEN);
for (Number n : Arrays.asList(lat, lon))
{
Double d = n.doubleValue();
System.out.println(df.format(d));
}
}
For example if I have 2.34 I want the randomized to be something like 2.493473 or 2.294847 or 2.346758
The first decimal point in which in this case is 3 from 2.34 should only change a maximum of one digit. Up or down randomly. The leading decimal points can change to anything in a random fashion.
What would be the best way of doing this?