package Integer import NoWurst import Real public constant INT_MAX = 2147483647 public constant INT_MIN = -2147483648 /** Returns the absolute value of this int */ public function int.abs() returns int return this < 0 ? -this : this /** Returns the square of this int */ public function int.squared() returns int return this * this /** returns the sign of the int */ public function int.sign() returns int return (this > 0 ? 1 : (this < 0 ? -1 : 0)) /** Limits this int to the given range */ public function int.clamp(int lowerBound, int higherBound) returns int return (this <= lowerBound ? lowerBound : (this >= higherBound ? higherBound : this)) /** Returns the int as real */ public function int.toReal() returns real return this * 1. /** Returns the string representation of this int */ public function int.toString() returns string return I2S(this) /** Returns this int to the power of the argument int */ public function int.pow(int x) returns int int result = 1 for int i=1 to x result *= this return result /** Linear Interpolation with alphafactor(smoothness) */ public function int.lerp(int target, real alpha) returns int return ((this * (1 - alpha)) + (target * alpha)).round() /** Checks if this int is between low and high value */ public function int.isBetween(int low, int high) returns bool return this >= low and this <= high /** Returns the result of a bitwise AND operation performed on this int and the argument int. */ public function int.bitAnd(int other) returns int return BlzBitAnd(this, other) /** Returns the result of a bitwise OR operation performed on this int and the argument int. */ public function int.bitOr(int other) returns int return BlzBitOr(this, other) /** Returns the result of a bitwise exclusive OR operation performed on this int and the argument int. */ public function int.bitXor(int other) returns int return BlzBitXor(this, other) /** Checks whether this int is odd. */ public function int.isOdd() returns boolean return BlzBitAnd(this, 1) == 1 /** Checks whether this int is even. */ public function int.isEven() returns boolean return not this.isOdd()