diff -r b9bf26ea0118 -r b2731af0357d emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js --- a/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js Thu Feb 07 17:41:41 2013 +0100 +++ b/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js Fri Feb 15 16:06:12 2013 +0100 @@ -212,6 +212,14 @@ }; (function(numberPrototype) { + function __handleDivByZero() { + var exception = new vm.java_lang_ArithmeticException; + vm.java_lang_ArithmeticException(false).constructor + .cons__VLjava_lang_String_2.call(exception, "/ by zero"); + + throw exception; + } + function __Int64(hi32, lo32) { this.hi32 = hi32 | 0; this.lo32 = lo32 | 0; @@ -438,11 +446,27 @@ r.setDigit(j + n, nrm, uj); } } - + + numberPrototype.div32 = function(x) { + if (x === 0) { + __handleDivByZero(); + } + + return (this / x) | 0; + } + + numberPrototype.mod32 = function(x) { + if (x === 0) { + __handleDivByZero(); + } + + return (this % x); + } + numberPrototype.div64 = function(x) { var negateResult = false; var u, v; - + if ((this.high32() & 0x80000000) != 0) { u = this.neg64(); negateResult = !negateResult; @@ -458,7 +482,7 @@ } if ((v === 0) && (v.high32() === 0)) { - // TODO: throw + __handleDivByZero(); } if (u.high32() === 0) { @@ -499,7 +523,7 @@ } if ((v === 0) && (v.high32() === 0)) { - // TODO: throw + __handleDivByZero(); } if (u.high32() === 0) {