1 33 package net.sf.jga.fn.arithmetic; 34 35 42 43 class ShortMath implements IntegerArithmetic<Short > { 44 45 static final long serialVersionUID = 9167946402888608933L; 46 47 static private final Short ZERO = new Short ((short) 0); 48 static private final Short ONE = new Short ((short) 1); 49 50 54 55 public Short valueOf(Number value) throws IllegalArgumentException { 56 return new Short (value.shortValue()); 57 } 58 59 62 63 public Short zero() { 64 return ZERO; 65 } 66 67 70 71 public Short one() { 72 return ONE; 73 } 74 75 79 80 public Short plus (Short x, Short y) { 81 return new Short ((short) (x.shortValue() + y.shortValue())); 82 } 83 84 88 89 public Short minus (Short x, Short y) { 90 return new Short ((short) (x.shortValue() - y.shortValue())); 91 } 92 93 97 98 public Short multiplies (Short x, Short y){ 99 return new Short ((short) (x.shortValue() * y.shortValue())); 100 } 101 102 103 107 108 public Short divides (Short x, Short y) { 109 return new Short ((short) (x.shortValue() / y.shortValue())); 110 } 111 112 116 117 public Short negate (Short x) { 118 return new Short ((short) -x.shortValue()); 119 } 120 121 125 126 public Short modulus (Short x, Short y) { 127 return new Short ((short) (x.shortValue() % y.shortValue())); 128 } 129 133 134 public Short and (Short x, Short y) { 135 return new Short ((short) (x.shortValue() & y.shortValue())); 136 } 137 138 142 143 public Short or (Short x, Short y) { 144 return new Short ((short) (x.shortValue() | y.shortValue())); 145 } 146 147 151 152 public Short xor (Short x, Short y) { 153 return new Short ((short) (x.shortValue() ^ y.shortValue())); 154 } 155 156 160 161 public Short not (Short x) { 162 return new Short ((short) ~x.shortValue()); 163 } 164 165 166 169 170 public Short shiftLeft(Short x, Integer y) { 171 return new Short ((short) (x.shortValue() << y.intValue())); 172 } 173 174 177 178 public Short signedShiftRight(Short x, Integer y) { 179 return new Short ((short) (x.shortValue() >> y.intValue())); 180 } 181 182 186 187 public Short unsignedShiftRight(Short x, Integer y) { 188 return new Short ((short) (x.shortValue() >>> y.intValue())); 189 } 190 } 191 | Popular Tags |