Gabriel Sechan wrote:
He's wrong about the results of the bug- he says in C it overflows by going to an invalid index via underflow. In C, you'd use an unsigned int (does Java have this?) thus wouldn't go to a negative index (although it is still a bug, it won't crash the app. It may infinite loop). IF a variable is supposed to be a loop index, it should always be unsigned in any language.

Sigh.  Boil the frog gradually ...

You are treating the symptom rather than the problem.

The bug is in handling integers. There are two options for integer overflow:

1) Die.  Period.  Do not silently truncate, overflow, saturate, or whatever.

2) Gracefully degrade. Switch to a slower version of integer which can handle the greater required precision. eg. Lisp bignums, Python longs, or Java BigInteger.

I wish language designers would just finally get it through their heads that int's should have infinite precision and floating point numbers should be *decimal* floating point instead of *binary* floating point.

It would save *so* much time and trouble.

-a

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to