This isn't the first time we've seen programmers having a difficult time gasping the intricacies of negative numbers. Heck, I'm sure we all had a little difficulty understanding at first, in the fifth grade. But you'd really think that someone able to program (am I giving too much credit here?), would have a little more sophistication than to distinguish positive and negative numbers with the “little line thing“ in prefixing the number.
//return whether a double is negative bool IsNegative(double n) { string nStr = n.ToString(); if (nstr.IndexOf('-', 0, 1)) return true; return false; }
I must say, I do appreciate the irony that many students shy away from Computer Science because they fear the complicated math. If only they knew.
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!