mapbox-unity-sdk icon indicating copy to clipboard operation
mapbox-unity-sdk copied to clipboard

Vector2d.ToString() - Why limit to 5 decimals when geocodes can be 6?

Open Alexphauge opened this issue 8 years ago • 2 comments

I just noticed something we've now changed internally, as it provided a bit of some confusion for some time, as we were printing Vector2d to Debug.Log, and thought we got wrong latitude/longitude.

We have now changed the code to public override string ToString() { return string.Format(NumberFormatInfo.InvariantInfo, "{0:F6},{1:F6}", this.y, this.x); }

Any reason for the 5 decimals limit instead of 6?

Alexphauge avatar Dec 15 '17 13:12 Alexphauge

@Alexphauge ah nice catch, sorry about that. I can't think of any reason really, it was probably just a mistake. ToString is always risky for debugging though, as you may not notice if ToString method is overriden etc. if you haven't particularly checked it. Lost me so much time before as well. If I remember correctly, Unity still uses F1 for float ToString for example. But maybe it's a little safer as it looks wrong right away.

brnkhy avatar Dec 15 '17 13:12 brnkhy

No worries, it only wasted about 10 minutes trying to figure out what was going on. :)

Alexphauge avatar Dec 15 '17 14:12 Alexphauge