Re: Euphoria versus Java

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Sun, 6 Apr 2003 15:32:06 -0300, rforno at tutopia.com wrote:

>I'm using a bit of Java now, and I noticed the following: while Java
>routinely performs a subscript checking (unlike C/C++), it does not =
verify
>if byte, short, integer or long variables overflow. So, if you have:
>byte x =3D 127;
>x =3D x + 1;
>you end up with x =3D -128 instead of getting an overflow error.
>Please correct me if there is a way of checking for this kind of error
>(someone in the list may know more Java than I do ;)).

Java uses the ansi standard C overflow checking model. Basically, when
overflow occurs, some useless rubbish is stored in the result field...
and then program execution continues at the next statement blink

In C# instead of z=3Dx+y you can just simply(!!) write:

	try {
	        z =3D checked(x + y);
	}
	catch (System.OverflowException e) {
	        System.Console.WriteLine(e.ToString());
	}

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu