|
|
|
|
|
by ynik
1094 days ago
|
|
`0.001` and `0.002` are essentially equally accurate as `1` and `2`.
`1.001` and `1.002` are worse. In general, multiplicative scaling is useless with floating-point (*); but shifting the coordinate offset (additive, i.e. translation) can be highly useful. You want to move the range of numbers you are dealing with so that is becomes centered around zero (not near 1!).
E.g. in Kerbal Space Program, the physics simulation of individual parts within the rocket needs to use a coordinate system centered on the rocket itself; it would be way too inaccurate to use the global coordinate system centered on the sun. (*) The exception is if you need to keep decimal fractions exact, e.g. if dealing with money. In this case, (if a better suited decimal floating-point is unavailable) you want to scale multiplicatively to ensure a cent is 1, not 0.01. |
|
Well let me just be 100% clear: I never meant to suggest the `1.001` encoding, at any point in this exchange (:
> You want to move the range of numbers you are dealing with so that is becomes centered around zero (not near 1!)
Yes, I think I like that terminology better - "centered around" rather than "near".
The reason I didn't say 0 originally is because keeping numbers "near zero" in an absolute sense is not the goal. If your numbers are all close to 1e-8, you would do well to scale them so that "1 float unit" is the size of the thing you care about, before doing your math. I think that is what you are saying in your cents example, too. So, the goal is about what "1 unit" means, not being specifically near a certain value. That's where the "1" in my original phrasing comes from; sorry for the confusion.