logo

const final class

sys::Int

sys::Obj
  sys::Num
    sys::Int

Int is used to represent a signed 64-bit integer.

Slots

abs

Int abs()

Return the absolute value of this integer. If this value is positive then return this, otherwise return the negation.

Source

and

Int and(Int b)

Bitwise-and of this and b. Shortcut is a&b.

Source

compare

override Int compare(Obj obj)

Compare based on integer value.

Source

decrement

Int decrement()

Decrement by one. Shortcut is --a or a--.

Source

div

Int div(Int b)

Divide this by b. Shortcut is a/b.

Source

equals

override Bool equals(Obj obj)

Return true if same integer value.

Source

fromDigit

Int fromDigit(Int radix := 10)

Convert a Unicode digit character into a number for the specified radix. Return null if this char is not a valid digit.

Example:

'3'.fromDigit     => 3
'f'.fromDigit(16) => 15
'%'.fromDigit     => null

Source

fromStr

static Int fromStr(Str s, Int radix := 10, Bool checked := true)

Parse a Str into a Int using the specified radix. If invalid format and checked is false return null, otherwise throw ParseErr.

Source

hash

override Int hash()

Return this.

Source

increment

Int increment()

Increment by one. Shortcut is ++a or a++.

Source

inverse

Int inverse()

Bitwise inverse of this. Shortcut is ~a.

Source

isAlpha

Bool isAlpha()

Return if this Unicode char is an ASCII alpha char: isUpper||isLower

Source

isAlphaNum

Bool isAlphaNum()

Return if this Unicode char is an ASCII alpha-numeric char: isAlpha||isDigit

Source

isDigit

Bool isDigit(Int radix := 10)

Return if this Unicode char is an digit in the specified radix. A decimal radix of ten returns true for 0-9. A radix of 16 also returns true for a-f and A-F.

Example:

'3'.toDigit     => true
3.toDigit       => false
'B'.toDigit(16) => true

Source

isEven

Bool isEven()

Return if this integer is evenly divisible by two.

Source

isLower

Bool isLower()

Return if this Unicode char is an ASCII lowercase alphabetic char: a-z

Source

isOdd

Bool isOdd()

Return if this integer is not evenly divisible by two.

Source

isSpace

Bool isSpace()

Return if this Unicode char is whitespace: space \t \n \r \f

Source

isUpper

Bool isUpper()

Return if this Unicode char is an ASCII uppercase alphabetic char: A-Z

Source

localeIsLower

Bool localeIsLower()

Return if this Unicode char is a lowercase letter in the current locale. See also localeIsUpper and isLower.

Source

localeIsUpper

Bool localeIsUpper()

Return if this Unicode char is an uppercase letter in the current locale. See also localeIsLower and isUpper.

Source

localeLower

Int localeLower()

If this Unicode char is an uppercase char, then return it as lowercase according to the current locale. Note that Unicode contains some case conversion rules that don't work correctly on a single character, so Str.localeLower should be preferred. See also localeUpper and lower.

Source

localeUpper

Int localeUpper()

If this Unicode char is a lowercase char, then return it as uppercase according to the current locale. Note that Unicode contains some case conversion rules that don't work correctly on a single character, so Str.localeLower should be preferred. See also localeLower and upper.

Source

lower

Int lower()

If this Unicode char is an ASCII uppercase char, then return it as lowercase, otherwise return this.

Example:

'A'.lower => 'a'
'h'.lower => 'h'

Source

lshift

Int lshift(Int b)

Bitwise left shift of this by b. Shortcut is a<<b.

Source

max

Int max(Int that)

Return the larger of this and the specified Int values.

Source

maxValue

static Int maxValue

Maximum value which can be stored in a signed 64-bit Int: 9,223,372,036,854,775,807

Source

min

Int min(Int that)

Return the smaller of this and the specified Int values.

Source

minValue

static Int minValue

Minimum value which can be stored in a signed 64-bit Int: -9,223,372,036,854,775,808

Source

minus

Int minus(Int b)

Subtract b from this. Shortcut is a-b.

Source

mod

Int mod(Int b)

Return remainder of this divided by b. Shortcut is a%b.

Source

mult

Int mult(Int b)

Multiply this with b. Shortcut is a*b.

Source

negate

Int negate()

Negative of this. Shortcut is -a.

Source

or

Int or(Int b)

Bitwise-or of this and b. Shortcut is a|b.

Source

plus

Int plus(Int b)

Add this with b. Shortcut is a+b.

Source

random

static Int random(Range r := null)

Generate a random number. If range is null then all 2^64 integer values (both negative and positive) are produced with equal probability. If range is non-null, then the result is guaranteed to be inclusive of the range.

Examples:

r := Int.random
r := Int.random(0..100)

Source

rshift

Int rshift(Int b)

Bitwise right shift of this by b. Shortcut is a>>b.

Source

times

Void times(|Int| c)

Call the specified function to this times passing the current counter.

Source

toChar

Str toChar()

Map as a Unicode code point to a single character Str.

Source

toDecimal

override Decimal toDecimal()

Convert this Int to a Decimal.

Source

toDigit

Int toDigit(Int radix := 10)

Convert this number into a Unicode char 0-'9'. If radix is is greater than 10, then use a lower case letter. Return null if this number cannot be represented as a single digit character for the specified radix.

Example:

3.toDigit      => '3'
15.toDigit(16) => 'f'
99.toDigit     => null

Source

toFloat

override Float toFloat()

Convert this Int to a Float.

Source

toHex

Str toHex(Int width := null)

Return hexdecimal string representation. If width is non-null, then leading zeros are prepended to ensure the specified number of nibble characters.

Examples:

255.toHex     =>  "ff"
255.toHex(4)  =>  "00ff"

Source

toInt

override Int toInt()

Return this.

Source

toStr

override Str toStr()

Return decimal string representation.

Source

upper

Int upper()

If this Unicode char is an ASCII lowercase char, then return it as uppercase, otherwise return this.

Example:

'a'.upper => 'A'
'4'.upper => '4'

Source

xor

Int xor(Int b)

Bitwise-exclusive-or of this and b. Shortcut is a^b.

Source