Anyway, it is not needed. Not now... |
It never was. I couldn't have possibly screwed that math up more if I tried, and I'm thoroughly embarrassed. I don't even know how I did it. Used to be quite good with mathematics...
But as closed account says, the reason (one of the reasons - the only reason at this point that really matters) is because it's a MASSIVE warning sign to whomever reads the code that I'm intentionally doing something that there's a chance I shouldn't be doing, and if nothing else, it's a great learning experience for you, because:
A) YOU SAW IT! You saw it clearly, and that's part of the point. The "old" style of doing it is:
Which is rather inconspicuous in large code. It's quite easy to miss. There are likely several variations, but the thing to remember is you're doing something that is questionable (which you questioned, and rightly so) but with the giant and ugly:
|
static_cast<double>(100 / occ[i]);
|
It's REALLY noticeable. Hard to miss, and you called me out on my nonsense, which in turn helped me to notice a serious flaw in the code itself. Well, I noticed it before, but you also brought up an excellent point which helped me see it easier. But also:
B) Sometimes you might need to use it if there are circumstances out of your control. This was MOST DEFINITELY NOT ONE OF THOSE TIMES. Not at all. Not even a little bit. If the math had been slightly more complicated, perhaps, but finding the instances of a number from 100 is CLEARLY not one of those times, and again, I'm embarrassed for even suggesting it, but I'll leave it because... well, I made my bed, so climb on in...