Skip to content

GPS accuracy and float precision #63

Closed
@ctorney

Description

@ctorney

Hi
I've recently started using this library and I've noticed there appears to be an issue with GPS accuracy loss due to parsing as a single precision float.

This was raised here #10 and a PR #12 was started but it looks like both were closed without fixing the issue.

It seems that the reason for closing the issue was because the truncated value can be printed to 6 decimal places (this is also written in the docs). But this isn't really a fix.

A float can be printed to more digits than its precision because of the error created when converting between binary and decimal.

Here's a quick illustration

>>> x = float('9.87654321')
>>> x
9.87654
>>> print("Original: 9.87654321, Truncated: {0:.8f} ".format(x))
Original: 9.87654321, Truncated: 9.87654114 

So while the float is printed to 8 decimal places the last 3 digits aren't related to the original value. It seems the same thing is happening with the latitude and longitude values - accuracy is lost from the location depending on the number of digits in the degrees.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions