Re: Arithmetic overflow checking
On 7/7/2011 7:11 AM, Peter Duniho wrote:
On 7/6/11 10:16 AM, Patricia Shanahan wrote:
On 7/6/2011 8:35 AM, rop rop wrote:
Hi,
If I want to have arithmetic-overflow checking in all parts of an
application,
what is the most practical, simple, efficient way to achieve this?
Write the application in Ada.
Or use C#, which has the same feature, but is a lot more like Java
otherwise.
That said, I suspect Tom's guess is correct and a language-change just
to achieve this goal isn't going to be the practical choice.
Like most design decisions, it is a trade-off. If Tom *needs* overflow
checking, the most practical, simple, efficient way to achieve it is to
use a language that is designed to support overflow checking.
If he merely *wants* overflow checking, the best choice may be to stick
to Java and drop general overflow checking. That does not prevent having
e.g. a BigInteger subclass that takes a range as a constructor parameter
and does overflow checking against that range.
I have not yet seen an option for getting general overflow checking in
Java, without getting false hits on code that depends on the JLS
specified arithmetic behavior, that is at all practical, simple, or
efficient.
Patricia