Hacker News new | ask | show | jobs
by ReleaseCandidat 847 days ago
> Changing well known behavior for something no one is really going to need.

On the contrary I can't imagine when and why anybody would want truncation. That's just a side effect of the used algorithm and not something that actually makes much (any?) sense.

1 comments

the post gives two examples:

- given a number t of seconds after the epoch, what time of day does it represent? using python's definition, (t + tz) % 86400

- given an offset d between two pixels in a pixel buffer organized into sequential lines, what is the x component of the offset? using python's definition, d % width is right when the answer is positive, width - (d % width) when the answer is negative, so you could write d % width - d > p0x ? d % width : width - d % width. this gets more complicated with the fortran definition, not simpler

edit: the correct expression is (d % width if p0x + d % width < width else d % width - width) or in c-like syntax (p0x + d % width < width ? d % width : d % width - width). see http://canonical.org/~kragen/sw/dev3/modpix.py