News for hackers. Stuff that matters.
Re:I open sourced my game along with a tutorial on how to ma... by anonymoushn on Monday July 06, 2020 @02:44AM (#23745319)
It's useful, if you are writing ternary search (over integers) or some such thing concerned with intervals, to be able to compute the length as hi-lo, and to be able to use hi<lo to check whether an interval is malformed, rather than writing hi-lo+1 and hi+1<lo. In the example about using modulo to place all integers into some interval upthread, most programming languages let you write (n-lo)%(hi-lo)+lo, but in Lua you should maybe write (n-lo)%(hi+1-lo)+lo. It doesn't seem like I am getting less likely to make errors here!

There are no comments on this comment yet.