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

zig-zag encoding is brilliant. Basically you can determine positive or negative based on odd/even and divide by 2 to get the value. I tried to come up with a similar encoding and never thought of this


It's the same as enumerating 2D points in a spiral, but restricted to 1D.


Yeah basically it's ones complement (or twos complement) but with the sign bit on the right, rather than the left.




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

Search: