Class RangeInt.PowerOfTwo

  • All Implemented Interfaces:
    Serializable, Cloneable
    Enclosing class:
    RangeInt

    public static class RangeInt.PowerOfTwo
    extends RangeInt
    Invariant representing longs whose values are always a power of 2 (exactly one bit is set). Used for non-instantiating suppressions. Since this is not covered by the Bound or OneOf invariants it is printed. Prints as x is a power of 2.
    See Also:
    Serialized Form
    • Field Detail

      • dkconfig_enabled

        public static boolean dkconfig_enabled
        Boolean. True if PowerOfTwo invariants should be considered.
    • Method Detail

      • enabled

        public boolean enabled()
        returns whether or not this invariant is enabled
        Specified by:
        enabled in class Invariant
      • get_format_str

        public String get_format_str​(@GuardSatisfied RangeInt.PowerOfTwo this,
                                     OutputFormat format)
        Description copied from class: RangeInt
        Return a format string for the specified output format. Each instance of %varN% will be replaced by the correct name for varN.
        Specified by:
        get_format_str in class RangeInt
      • eq_check

        public boolean eq_check​(long x)
        Returns true if x is a power of 2 (has one bit on). The check is to and x with itself - 1. The theory is that if there are multiple bits turned on, at least one of those bits is unmodified by a subtract operation and thus the bitwise-and be non-zero. There is probably a more elegant way to do this.
        Specified by:
        eq_check in class RangeInt