Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
dominikoeo
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
3 ms
·
1.
▲
by
dominikoeo
5y ago
Compilers have taken advantage of undefined behavior in signed overflow for many years now. So unless you use an very ancient compiler, your code is buggy. You are just lucky if it "appears" to work. What happens is that adding s
2.
▲
by
dominikoeo
5y ago
> It's very handy to represent angles as signed 16bit integers with a scaling of 2^15 = pi radians. And it is in incorrect as *signed* integer overflows are undefined behavior (at least in c++). It's only defined for unsigned i