3 ms·
Isn't that more of using a float to represent the number? Would be akin to trying to represent .5. Which, if your goal is to represent decimals, you are best
by taeric 7mo ago
Isn't that more of using a float to represent the number? Would be akin to trying to represent .5. Which, if your goal is to represent decimals, you are best off not using floats.
Granted, just storing it as a 32 bit integer is probably difficult for most uses. BCD just isn't common for most programmers. (Or fixed point, in general.)
- pezezin 7mo agoIf your goal is just to store the coordinates in a database, sure, use fixed point or whatever. But any kind of calculation will involve a great deal of trigonometry, square roots, and the like. It is just easier to use floating point. Examples: https://en.wikipedia.org/wiki/Geographic_coordinate_conversion https://en.wikipedia.org/wiki/Geographic_coordinate_conversi... https://en.wikipedia.org/wiki/Vincenty%27s_formulae https://en.wikipedia.org/wiki/Vincenty%27s_formulae https://gist.github.com/govert/1b373696c9a27ff4c72a https://gist.github.com/govert/1b373696c9a27ff4c72a
- taeric 7mo agoYou should be able to do the calculations in fixed point, easily enough? Indeed, it used to be that most embedded systems would use fixed point due to lack of float hardware. I would actually think fixed point would be beneficial for its accuracy being a bit more controlled than floating point is. Yes, you lose the range of floating point. But I just don't see how that is relevant for numbers that are constrained to +/- 180 by definition. That all said, I cannot and do not argue against that it is faster to get going with basic float/doubles, due to how commonly those are supported in base libraries.