UByte.java 767 B

1234567891011121314151617181920212223242526272829
  1. package gnu.math;
  2. public class UByte extends UnsignedPrim implements Comparable<UByte> {
  3. byte ival;
  4. public int numBits() { return 8; }
  5. public UByte(byte ival) { this.ival = ival; }
  6. public static UByte valueOf(byte ival) { return new UByte(ival); }
  7. public int intValue() { return ival & 0xFF; }
  8. public IntNum toIntNum() { return IntNum.valueOf(ival & 0xFFFF); }
  9. public boolean equals(Object obj) {
  10. return obj instanceof UByte
  11. && ival == ((UByte) obj).ival;
  12. }
  13. public int compareTo(UByte other) {
  14. return intValue() - other.intValue();
  15. }
  16. public static String toString(byte ival) {
  17. return Integer.toString(ival & 0xFF);
  18. }
  19. public String toString() { return toString(ival); }
  20. }