1 package org.codehaus.groovy.runtime; 2 3 8 public class BigIntegerMath extends NumberMath { 9 10 protected static BigIntegerMath instance = new BigIntegerMath(); 11 12 private BigIntegerMath() {} 13 14 protected Number absImpl(Number number) { 15 return toBigInteger(number).abs(); 16 } 17 18 protected Number addImpl(Number left, Number right) { 19 return toBigInteger(left).add(toBigInteger(right)); 20 } 21 22 protected Number subtractImpl(Number left, Number right) { 23 return toBigInteger(left).subtract(toBigInteger(right)); 24 } 25 26 protected Number multiplyImpl(Number left, Number right) { 27 return toBigInteger(left).multiply(toBigInteger(right)); 28 } 29 30 protected Number divideImpl(Number left, Number right) { 31 return BigDecimalMath.instance.divideImpl(left, right); 32 } 33 34 protected int compareToImpl(Number left, Number right) { 35 return toBigInteger(left).compareTo(toBigInteger(right)); 36 } 37 38 protected Number andImpl(Number left, Number right) { 39 return toBigInteger(left).and(toBigInteger(right)); 40 } 41 42 protected Number intdivImpl(Number left, Number right) { 43 return toBigInteger(left).divide(toBigInteger(right)); 44 } 45 46 protected Number modImpl(Number left, Number right) { 47 return toBigInteger(left).mod(toBigInteger(right)); 48 } 49 50 protected Number negateImpl(Number left) { 51 return toBigInteger(left).negate(); 52 } 53 54 protected Number orImpl(Number left, Number right) { 55 return toBigInteger(left).or(toBigInteger(right)); 56 } 57 } 58 | Popular Tags |