emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js
1.1 --- a/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js Thu Feb 07 17:41:41 2013 +0100
1.2 +++ b/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js Fri Feb 15 16:06:12 2013 +0100
1.3 @@ -212,6 +212,14 @@
1.4 };
1.5
1.6 (function(numberPrototype) {
1.7 + function __handleDivByZero() {
1.8 + var exception = new vm.java_lang_ArithmeticException;
1.9 + vm.java_lang_ArithmeticException(false).constructor
1.10 + .cons__VLjava_lang_String_2.call(exception, "/ by zero");
1.11 +
1.12 + throw exception;
1.13 + }
1.14 +
1.15 function __Int64(hi32, lo32) {
1.16 this.hi32 = hi32 | 0;
1.17 this.lo32 = lo32 | 0;
1.18 @@ -438,11 +446,27 @@
1.19 r.setDigit(j + n, nrm, uj);
1.20 }
1.21 }
1.22 -
1.23 +
1.24 + numberPrototype.div32 = function(x) {
1.25 + if (x === 0) {
1.26 + __handleDivByZero();
1.27 + }
1.28 +
1.29 + return (this / x) | 0;
1.30 + }
1.31 +
1.32 + numberPrototype.mod32 = function(x) {
1.33 + if (x === 0) {
1.34 + __handleDivByZero();
1.35 + }
1.36 +
1.37 + return (this % x);
1.38 + }
1.39 +
1.40 numberPrototype.div64 = function(x) {
1.41 var negateResult = false;
1.42 var u, v;
1.43 -
1.44 +
1.45 if ((this.high32() & 0x80000000) != 0) {
1.46 u = this.neg64();
1.47 negateResult = !negateResult;
1.48 @@ -458,7 +482,7 @@
1.49 }
1.50
1.51 if ((v === 0) && (v.high32() === 0)) {
1.52 - // TODO: throw
1.53 + __handleDivByZero();
1.54 }
1.55
1.56 if (u.high32() === 0) {
1.57 @@ -499,7 +523,7 @@
1.58 }
1.59
1.60 if ((v === 0) && (v.high32() === 0)) {
1.61 - // TODO: throw
1.62 + __handleDivByZero();
1.63 }
1.64
1.65 if (u.high32() === 0) {