Static Class in Zigurous.Math


public static class IntExtensions


Extension methods for integers.

Extension Methods

GetBitsReturns a subset of bits from the number.
HasFlagChecks if a given flag is set in the bitmask. (mask & flag) == flag
HasAnyFlagChecks if any of the given flags are set in the bitmask. (mask & flags) != 0
IsEvenChecks if the number is even. n % 2 == 0
IsOddChecks if the number is odd. n % 2 != 0
IsZeroChecks if the number is zero. n == 0
IsPositiveChecks if the number is positive. n > 0
IsNegativeChecks if the number is negative. n < 0
NumDigitsReturns the number of digits in the number.
ToAbbreviatedStringConverts the number to an abbreviated string, e.g. "1k" for 1000.
ToBinaryStringConverts the number to a string of binary digits.