简体   繁体   中英

Inaccurate values returning from Emulator Control of Eclipse

            //Show the current coordinates (Convert to String and round off - 6 decimal places)
        String printLat = new DecimalFormat("0.######").format((double)currentLat);
        String printLon = new DecimalFormat("0.######").format((double)currentLon);

        AlertDialog alert = new AlertDialog.Builder(Main.this).create();
        alert.setTitle("Current Location:");
        alert.setMessage("Latitude: " + printLat+ "\n" + "Longitude: " + printLon);
        alert.setButton("Close", new DialogInterface.OnClickListener()
        {               
            public void onClick(DialogInterface arg0, int arg1)
            {
                // TODO Auto-generated method stub
                //Alert Dialog won't work without a listener
                //Do nothing (This will simply close your alert dialog)
            }
        });     
        alert.show();

Here's a part of my main class.

I should obtain what I am sending from my emulator. But instead of retrieving exact values, I'm getting this:

Latitude - 14.069315 Longitude - 121.323738

but I sent this (from my Emulator Control) Latitude - 14.069316 Longitude - 121.323739

It's just a matter of one decimal number, and a small value, but I'm worried if this will take a big effect of what will appear on my application, because I will use these values to add markers on my Google Maps.

Any suggestions?

This sounds like rounding error to me.

I wouldn't worry about this amount of error, as the number at the sixth decimal place equates to less than 1 meter on the ground (depending what latitude the location is at) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM