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