Ask HN: Does anyone else not use greater than? 2 points by windows2020 3y ago ↗ HN Does anyone else not use > and >= and stick with only < and <=? If so, what was the inspiration?
[–] jjgreen 3y ago ↗ I do (er, don't) do that, mostly, just so the arguments are size-increasing if ((0 <= x) && (x < 10)) { ...
[–] mac3n 3y ago ↗ I always use <, <=, for consistency and to make the ordering clearin mathematical notation, 0 <= i < n is sometimes used for summations where i ranges from 0 through n-1
[–] grandmaa 3y ago ↗ I like to be fair to all the comparators and use the greater than, equal to or less than operator: <=> Admittedly it's only good for checking that a value isn't NaN.
[–] dave4420 3y ago ↗ I do that.I visualise the variables as being on the number line. If they’re the way round that they appear in the code, then the condition is true.Unfortunately my code reviewers tend not to like it when I write constant < variable.
[–] joshxyz 3y ago ↗ the inspiration is the number line, small numbers at the left, larger numbers at the right, because we write left to right, and the sequence is 1 2 3 4..which is why you always want the larger ones on the right.
8 comments
[ 3.8 ms ] story [ 26.9 ms ] threadin mathematical notation, 0 <= i < n is sometimes used for summations where i ranges from 0 through n-1
I visualise the variables as being on the number line. If they’re the way round that they appear in the code, then the condition is true.
Unfortunately my code reviewers tend not to like it when I write constant < variable.
which is why you always want the larger ones on the right.