Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The nice thing about turns is that they can be represented by an unsigned integer. For example with an 8 bit unsigned integer:

- 0000_0000 = 0 or tau

- 1000_0000 = pi

- 1100_0000 = 3*pi/4

And the addition and multiplication by integer scalars all apply and the overflows work naturally. I wrote a little library in rust [0] to help with this as you can define the operations */+-% etc.

[0] https://docs.rs/turns/latest/turns/



Ooh! that overflow is so clever. I would have been proud to have thought of that. Perfect fit for modular arithmetic.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: