2 ms·
Is it just me or does dividing an integer always turn on some alarm bells in my head? I'd immediately look into what happens for odd numbers, rounding, implici
by koyote 1y ago
Is it just me or does dividing an integer always turn on some alarm bells in my head?
I'd immediately look into what happens for odd numbers, rounding, implicit type conversions etc. Or at least that's what I was taught when I first started programming.
Also relying on "well we know that X is always Y" is almost always a mistake; maybe not always at first but definitely in the future because X will almost certainly be Y at some point. Defensive coding would catch such issues (with at the very least an Assert somewhere to ensure X is indeed Y before continuing, ensuring that we get a nice error when that assumption proves to be wrong).