HackerTrans
TopNewTrendsCommentsPastAskShowJobs

venning

1,246 karmajoined vor 12 Jahren
Christopher Venning

comments

venning
·letztes Jahr·discuss
It may be worth pointing out: these are equivalent comparisons when testing for even numbers but cannot be extrapolated to testing for odd numbers. The reason being that a negative odd number modulus 2 is -1, not 1.

So `n % 2 == 1` should probably [1] be replaced with `n % 2 != 0`.

While this may be obvious with experience, if the code says `n % 2 == 0`, then a future developer who is trying to reverse the operation for some reason must know that they need to change the equality operator not the right operand. Whereas, with `n % 1 == 0`, they can change either safely and get the same result.

This feels problematic because the business logic that necessitated the change may be "do this when odd" and it may feel incorrect to implement "don't do this when even".

I really disfavor writing code that could be easily misinterpreted and modified in future by less-experienced developers; or maybe just someone (me) who's tired or rushing. For that reason, and the performance one, I try to stick to the bitwise operator.

[1] Of course, if for some reason you wanted to test for only positive odd numbers, you could use `n % 2 == 1`, but please write a comment noting that you're being clever.
venning
·vor 2 Jahren·discuss
From the linked study: [1]

Total operational water "footprint" of data centers in 2018: 5.13 * 10^8 m^3. Of that, indirect consumption through electricity generation: 3.83 * 10^8 m^3, or 74.7%. And indirect consumption related to water and wastewater utilities (non-electicity production): 4.50 * 10^5 m^3, or 0.09%.

The study then does a reasonable job of discussing the concerns of building data centers in water-stressed places.

This article seems to be another "didn't read the study, saw big number" thing.

[1] https://iopscience.iop.org/article/10.1088/1748-9326/abfba1 (PDF page 7, section 3.1)
venning
·vor 11 Jahren·discuss
DC is definitionally composed of people carrying opinions across the spectrum. Being vocally opposed to those things you list is actually a job requirement for some places. DC's stereotype is a bit unnuanced.