| ▲ | adrian_b 6 hours ago | |
Having a constant relative error is indeed the reason for using floating-point numbers. However, for angles the relative error is completely irrelevant. For angles only the absolute error matters. For angles the optimum representation is as fixed-point numbers, not as floating-point numbers. | ||
| ▲ | Dylan16807 42 minutes ago | parent | next [-] | |
The absolute error accounting for units is what matters. Changing the unit gives the illusion of changing absolute error, but doesn't actually change the absolute error. | ||
| ▲ | valicord 6 hours ago | parent | prev | next [-] | |
With -π to π radians you get absolute error of approximately 4e-16 radians. With -180 to 180 degrees you get absolute error of approximately 2e-14 degrees. Even though the first number is smaller than the 2nd one, they actually represent the same angle once you consider that they are different units. So there's no precision advantage (absolute or relative) to converting degrees to radians. Note that I'm not saying anything about fixed vs floating point, only responding to an earlier comment that radians give more precision in floating point representation. | ||
| ▲ | ryandrake 6 hours ago | parent | prev [-] | |
Yep, it was a long time ago but I think that's exactly what we ended up with, eventually: An int type of unit 2π/(int range). I believe we used unsigned because signed int overflow is undefined behavior. | ||