@haxall/haxall
    Preparing search index...

    Class Int

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

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    type$: Type

    Methods

    • Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:

      this < that   =>  <0
      this == that => 0
      this > that => >0

      This method may also be accessed via the < <= <=> >= and > shortcut operators. If not overridden the default implementation compares the toStr representations. Also see docLang.

      Examples:

      3.compare(8)  =>  -1
      8.compare(3) => 1
      8.compare(8) => 0
      3 <=> 8 => -1 // shortcut for 3.compare(8)

      Parameters

      Returns number

    • Compare this object to the specified for equality. This method may be accessed via the == and != shortcut operators. If not overridden the default implementation compares for reference equality using the === operator. If this method is overridden, then hash() must also be overridden such that any two objects which return true for equals() must return the same value for hash(). This method must accept null and return false.

      Parameters

      Returns boolean

    • Return a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.

      Returns number

    • Return if this Obj is immutable and safe to share between threads:

      • an instance of a const class
      • the result of toImmutable on List, Map, or Buf
      • a Func object may or may not be immutable - see sys::Func.
      • other instances are assumed mutable and return false

      Returns boolean

    • Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:

      • if type is const, return this
      • if already an immutable List, Map, Buf, or Func return this
      • if a List, then attempt to perform a deep clone by calling toImmutable on all items
      • if a Map, then attempt to perform a deep clone by calling toImmutable on all values (keys are already immutable)
      • some Funcs can be made immutable - see sys::Func
      • if a Buf create immutable copy, see sys::Buf
      • any other object throws NotImmutableErr

      Returns Readonly<this>

    • Return a string representation of this object.

      Returns string

    • Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:

      a->x        a.trap("x", null)
      a->x() a.trap("x", null)
      a->x = b a.trap("x", [b])
      a->x(b) a.trap("x", [b])
      a->x(b, c) a.trap("x", [b, c])

      The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.

      Parameters

      Returns JsObj

    • Get the Type instance which represents this object's class. Also seeType.of or Pod.of.

      Returns Type

    • This method called whenever an it-block is applied to an object. The default implementation calls the function with this, and then returns this.

      Parameters

      • f: (arg0: this) => void

      Returns this

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

      Parameters

      • self: number

      Returns number

    • Bitwise-and of this and b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Clamp this integer between the min and max. If it's less than min then return min, if it's greater than max return max, otherwise return this integer itself.

      Parameters

      • self: number
      • min: number
      • max: number

      Returns number

    • Compare based on integer value.

      Parameters

      Returns number

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

      Parameters

      • self: number

      Returns number

    • Default value is zero.

      Returns number

    • Divide this by b. Shortcut is a/b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Divide this by b. Shortcut is a/b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Divide this by b. Shortcut is a/b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Write x.toStr to standard output followed by newline. If x is null then print "null". If no argument is provided then print an empty line.

      Parameters

      Returns void

    • Return true if same integer value.

      Parameters

      Returns boolean

    • Return if the two Unicode chars are equal without regard to ASCII case.

      Parameters

      • self: number
      • ch: number

      Returns boolean

    • 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

      Parameters

      • self: number
      • Optionalradix: number

      Returns number

    • Parse a Str into a Int using the specified radix. Unless the radix is 10, then a leading minus sign is illegal. If invalid format and checked is false return null, otherwise throw ParseErr.

      Parameters

      • s: string
      • Optionalradix: number
      • Optionalchecked: boolean
      • ...args: unknown[]

      Returns Int

    • Return this.

      Parameters

      • self: number

      Returns number

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

      Parameters

      • self: number

      Returns number

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

      Parameters

      • self: number

      Returns boolean

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

      Parameters

      • self: number

      Returns boolean

    • Return if this Unicode char is a 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

      Parameters

      • self: number
      • Optionalradix: number

      Returns boolean

    • Return if this integer is evenly divisible by two.

      Parameters

      • self: number

      Returns boolean

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

      Parameters

      • self: number

      Returns boolean

    • Return if this integer is not evenly divisible by two.

      Parameters

      • self: number

      Returns boolean

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

      Parameters

      • self: number

      Returns boolean

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

      Parameters

      • self: number

      Returns boolean

    • Get the current locale's decimal separator. For example in the the US this is a dot.

      Returns string

    • Get the current locale's separator for grouping thousands together. For example in the US this is a comma.

      Returns string

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

      Parameters

      • self: number

      Returns boolean

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

      Parameters

      • self: number

      Returns boolean

    • 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.

      Parameters

      • self: number

      Returns number

    • Get the current locale's minus sign used to represent a negative number.

      Returns string

    • Get the current locale's string representation for not-a-number.

      Returns string

    • Get the current locale's string representation for negative infinity.

      Returns string

    • Get the current locale's symbol for the percent sign.

      Returns string

    • Get the current locale's string representation for positive infinity.

      Returns string

    • 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.localeUpper should be preferred. See also localeLower and upper.

      Parameters

      • self: number

      Returns number

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

      Example:

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

      Parameters

      • self: number

      Returns number

    • Return the larger of this and the specified Int values.

      Parameters

      • self: number
      • that: number

      Returns number

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

      Returns number

    • Return the smaller of this and the specified Int values.

      Parameters

      • self: number
      • that: number

      Returns number

    • Subtract b from this. Shortcut is a-b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Subtract b from this. Shortcut is a-b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Subtract b from this. Shortcut is a-b.

      Parameters

      • self: number
      • b: number

      Returns number

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

      Returns number

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

      Parameters

      • self: number
      • b: number

      Returns number

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

      Parameters

      • self: number
      • b: number

      Returns number

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

      Parameters

      • self: number
      • b: number

      Returns number

    • Multiply this with b. Shortcut is a*b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Multiply this with b. Shortcut is a*b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Multiply this with b. Shortcut is a*b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Negative of this. Shortcut is -a.

      Parameters

      • self: number

      Returns number

    • Bitwise not/inverse of this.

      Parameters

      • self: number

      Returns number

    • Bitwise-or of this and b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Add this with b. Shortcut is a+b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Add this with b. Shortcut is a+b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Add this with b. Shortcut is a+b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Return this value raised to the specified power. Throw ArgErr if pow is less than zero.

      Parameters

      • self: number
      • pow: number

      Returns number

    • 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. Also see Float.random , Range.random , List.random , and util::Random.

      Examples:

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

      Parameters

      Returns number

    • Bitwise arithmetic right-shift of this by b. The left-most bit is shifted into the highest bits performing like a signed shift. This is equivalent to the Java >> operator.

      Parameters

      • self: number
      • b: number

      Returns number

    • Bitwise left shift of this by b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Bitwise right shift of this by b. Zero is shifted into the highest bits performing like an unsigned shift. This is equivalent to the Java >>> operator.

      Parameters

      • self: number
      • b: number

      Returns number

    • Call the specified function to this times passing the current counter. The counter begins at zero. Also see Range.each.

      Example:

      3.times |i| { echo(i) }  =>  0, 1, 2
      

      Parameters

      • self: number
      • c: (arg0: number) => void

      Returns void

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

      Parameters

      • self: number

      Returns string

    • Get this Int as a Fantom code literal. Base must be 10 or 16.

      Parameters

      • self: number
      • Optionalbase: number

      Returns string

    • Convert nano-seconds ticks since 1-Jan-2000 to a DateTime. Convenience for DateTime.makeTicks.

      Parameters

      Returns DateTime

    • Convert this number to a Decimal.

      Parameters

      • self: number

      Returns number

    • Convert this number into a Unicode char 0-'9'. If radix 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

      Parameters

      • self: number
      • Optionalradix: number

      Returns number

    • Convert nano-seconds ticks to a Duration. Convenience for Duration.make.

      Parameters

      • self: number

      Returns Duration

    • Convert this number to a Float.

      Parameters

      • self: number

      Returns number

    • 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"

      Parameters

      • self: number
      • Optionalwidth: number

      Returns string

    • Convert this number to an Int.

      Parameters

      • self: number

      Returns number

    • Format this integer number for the current locale. If pattern is null, then the locale's default pattern is used. See Float.toLocale for pattern language. Fractional formatting is not supported for integers.

      In addition Int.toLocale supports the "B" pattern which will format a number of bytes with the appropriate B, KB, MB, GB suffix based on the magnitude (1024B == 1KB).

      Examples:

      3.toLocale("00")             =>  03
      3.toLocale("000") => 003
      123456789.toLocale("#,###") => 123,456,789
      123.toLocale("B") => 123B
      1234.toLocale("B") => 1.2KB
      100_000.toLocale("B") => 98KB
      (3*1024*1024).toLocale("B") => 3MB

      Parameters

      • self: number
      • Optionalpattern: string
      • Optionallocale: Locale

      Returns string

    • Return string representation in given radix. If width is non-null, then leading zeros are prepended to ensure the specified width.

      Examples:

      255.toRadix(8)    =>  "377"
      255.toRadix(8, 5) => "00377"

      Parameters

      • self: number
      • radix: number
      • Optionalwidth: number

      Returns string

    • Return decimal string representation.

      Parameters

      • self: number

      Returns string

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

      Example:

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

      Parameters

      • self: number

      Returns number

    • Bitwise-exclusive-or of this and b.

      Parameters

      • self: number
      • b: number

      Returns number