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