< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/UnsignedLong.java

Print this page




  26 
  27 public final class UnsignedLong {
  28     private final long value;
  29 
  30     public UnsignedLong(long value) {
  31         this.value = value;
  32     }
  33 
  34     public long asLong() {
  35         return value;
  36     }
  37 
  38     public boolean equals(long unsignedValue) {
  39         return value == unsignedValue;
  40     }
  41 
  42     public boolean isLessThan(long unsignedValue) {
  43         return Long.compareUnsigned(value, unsignedValue) < 0;
  44     }
  45 




  46     public boolean isLessOrEqualTo(long unsignedValue) {
  47         return Long.compareUnsigned(value, unsignedValue) <= 0;
  48     }
  49 
  50     public UnsignedLong times(long unsignedValue) {
  51         if (unsignedValue != 0 && Long.compareUnsigned(value, Long.divideUnsigned(0xffff_ffff_ffff_ffffL, unsignedValue)) > 0) {
  52             throw new ArithmeticException();
  53         }
  54         return new UnsignedLong(value * unsignedValue);
  55     }
  56 
  57     public UnsignedLong minus(long unsignedValue) {
  58         if (Long.compareUnsigned(value, unsignedValue) < 0) {
  59             throw new ArithmeticException();
  60         }
  61         return new UnsignedLong(value - unsignedValue);
  62     }
  63 
  64     public UnsignedLong plus(long unsignedValue) {
  65         if (Long.compareUnsigned(0xffff_ffff_ffff_ffffL - unsignedValue, value) < 0) {




  26 
  27 public final class UnsignedLong {
  28     private final long value;
  29 
  30     public UnsignedLong(long value) {
  31         this.value = value;
  32     }
  33 
  34     public long asLong() {
  35         return value;
  36     }
  37 
  38     public boolean equals(long unsignedValue) {
  39         return value == unsignedValue;
  40     }
  41 
  42     public boolean isLessThan(long unsignedValue) {
  43         return Long.compareUnsigned(value, unsignedValue) < 0;
  44     }
  45 
  46     public boolean isGreaterThan(long unsignedValue) {
  47         return Long.compareUnsigned(value, unsignedValue) > 0;
  48     }
  49 
  50     public boolean isLessOrEqualTo(long unsignedValue) {
  51         return Long.compareUnsigned(value, unsignedValue) <= 0;
  52     }
  53 
  54     public UnsignedLong times(long unsignedValue) {
  55         if (unsignedValue != 0 && Long.compareUnsigned(value, Long.divideUnsigned(0xffff_ffff_ffff_ffffL, unsignedValue)) > 0) {
  56             throw new ArithmeticException();
  57         }
  58         return new UnsignedLong(value * unsignedValue);
  59     }
  60 
  61     public UnsignedLong minus(long unsignedValue) {
  62         if (Long.compareUnsigned(value, unsignedValue) < 0) {
  63             throw new ArithmeticException();
  64         }
  65         return new UnsignedLong(value - unsignedValue);
  66     }
  67 
  68     public UnsignedLong plus(long unsignedValue) {
  69         if (Long.compareUnsigned(0xffff_ffff_ffff_ffffL - unsignedValue, value) < 0) {


< prev index next >