1 8 package org.lsmp.djep.groupJep.groups; 9 import org.lsmp.djep.groupJep.interfaces.*; 10 11 15 public class Reals extends Group implements FieldI,OrderedSetI,HasPowerI { 16 17 private Double ZERO = new Double (0.0); 18 private Double ONE = new Double (1.0); 19 20 23 public Reals() { 24 } 25 26 public Number getZERO() { 27 return ZERO; 28 } 29 30 public Number getONE() { 31 return ONE; 32 } 33 34 public Number getInverse(Number num) { 35 return new Double (1.0/num.doubleValue()); 36 } 37 38 public Number getMulInverse(Number num) { 39 return new Double (1.0 / num.doubleValue()); 40 } 41 42 public Number add(Number a, Number b) { 43 return new Double (a.doubleValue()+b.doubleValue()); 44 } 45 46 public Number sub(Number a, Number b) { 47 return new Double (a.doubleValue()-b.doubleValue()); 48 } 49 50 public Number mul(Number a, Number b) { 51 return new Double (a.doubleValue()*b.doubleValue()); 52 } 53 54 public Number div(Number a, Number b) { 55 return new Double (a.doubleValue()/b.doubleValue()); 56 } 57 58 public Number pow(Number a, Number b) { 59 return new Double (Math.pow(a.doubleValue(),b.doubleValue())); 60 } 61 62 public Number valueOf(String str) { 63 return new Double (str); 64 } 65 66 public boolean equals(Number a,Number b) { 67 return ((Double ) a).compareTo((Double ) b) == 0; 68 } 69 70 public int compare(Number a,Number b) { 71 return ((Double ) a).compareTo((Double ) b); 72 } 73 } 74 | Popular Tags |