Orchid Win7 v1 <voi### [at] devnull> wrote:
> int abs(int input)
> {
> int value = 0;
> for (int n = input; n != 0; n++)
> {
> value++;
> }
> return value;
> }
Having been a teaching assistant at the computing science lab, I got to
see some pretty weird programs made by students.
For example, you wouldn't believe how complicated calculating the length
of a 2D vector can become in the hands of an inexperienced programmer.
(This should be a literal one-liner, yet even 100 lines of code were
regularly broken just to do this simple thing.)
> * return sqrt(x*x); // Evil.
Many C and C++ compilers will actually optimize that to abs(x). I wouldn't
be surprised if a C# compiler wouldn't do the same...
--
- Warp
Post a reply to this message
|