Home > Blockchain >  QueryString param value being changed in C# Core
QueryString param value being changed in C# Core

Time:10-11

We have a C# Core 3 webapi.A variable value is being changed, I am not sure why this could be happening, any ideas?

A GET is sending the following params ?latitude=33.96568046240656&longitude=-84.325648999999980&distance=50000000

The controller function is here:

        [HttpGet]
    public async Task<List<NearbyLocation>> GetNearbyLocations(
        [FromQuery] Double latitude,
        [FromQuery] Double longitude,
        [FromQuery] long distance = 50000,
        [FromQuery] int quantity = 10
        )
    {
        return await _geoTrackService.GetNearbyLocations(latitude, longitude, distance, quantity);
    }

The sent variable longitude shows with a value of -84.325648999999980

The code variable longitude shows with a value of -84.325648999999984

How is this possible?

CodePudding user response:

The floating point rounding accours. The good thing is that you don't need Decimals to save GPS coordinates. The 5 or6 decimals are usually ok for practical use.

https://gis.stackexchange.com/questions/8650/measuring-accuracy-of-latitude-and-longitude

  • Related