1 8 package org.lsmp.djep.groupJep.groups; 9 import java.math.*; 10 11 import org.lsmp.djep.groupJep.interfaces.*; 12 13 19 public class Integers extends Group implements IntegralDomainI,HasDivI, 20 OrderedSetI,HasModI,HasPowerI { 21 22 25 public Integers() { 26 } 27 28 public Number getZERO() { 29 return BigInteger.ZERO; 30 } 31 32 public Number getONE() { 33 return BigInteger.ONE; 34 } 35 36 public Number getInverse(Number num) { 37 BigInteger a = (BigInteger) num; 38 return a.negate(); 39 } 40 41 public Number add(Number num1, Number num2) { 42 BigInteger a = (BigInteger) num1; 43 BigInteger b = (BigInteger) num2; 44 return a.add(b); 45 } 46 47 public Number sub(Number num1, Number num2) { 48 BigInteger a = (BigInteger) num1; 49 BigInteger b = (BigInteger) num2; 50 return a.subtract(b); 51 } 52 53 public Number mul(Number num1, Number num2) { 54 BigInteger a = (BigInteger) num1; 55 BigInteger b = (BigInteger) num2; 56 return a.multiply(b); 57 } 58 59 public Number div(Number num1, Number num2) { 60 BigInteger a = (BigInteger) num1; 61 BigInteger b = (BigInteger) num2; 62 return a.divide(b); 63 } 64 65 public Number mod(Number num1, Number num2) { 66 BigInteger a = (BigInteger) num1; 67 BigInteger b = (BigInteger) num2; 68 return a.remainder(b); 69 } 70 71 public Number pow(Number num1, Number num2) { 72 BigInteger a = (BigInteger) num1; 73 BigInteger b = (BigInteger) num2; 74 return a.pow(b.intValue()); 75 } 76 public boolean equals(Number a,Number b) { 77 return ((BigInteger) a).compareTo((BigInteger) b) == 0; 78 } 79 80 public int compare(Number a,Number b) { 81 return ((BigInteger) a).compareTo((BigInteger) b); 82 } 83 84 public Number valueOf(String str) { 85 return new BigInteger(str); 86 } 87 88 public String toString() { return "Z: integers"; } 89 } 90 | Popular Tags |