SignedInteger

public extension SignedInteger
  • abs

    SwifterSwift: Absolute value of integer number.

    Declaration

    Swift

    var abs: Self { get }
  • SwifterSwift: Check if integer is positive.

    Declaration

    Swift

    var isPositive: Bool { get }
  • SwifterSwift: Check if integer is negative.

    Declaration

    Swift

    var isNegative: Bool { get }
  • SwifterSwift: Check if integer is even.

    Declaration

    Swift

    var isEven: Bool { get }
  • SwifterSwift: Check if integer is odd.

    Declaration

    Swift

    var isOdd: Bool { get }
  • SwifterSwift: String of format (XXh XXm) from seconds Int.

    Declaration

    Swift

    var timeString: String { get }

Methods

  • SwifterSwift: Greatest common divisor of integer value and n.

    Declaration

    Swift

    func gcd(of number: Self) -> Self

    Parameters

    number

    integer value to find gcd with.

    Return Value

    greatest common divisor of self and n.

  • SwifterSwift: Least common multiple of integer and n.

    Declaration

    Swift

    func lcm(of number: Self) -> Self

    Parameters

    number

    integer value to find lcm with.

    Return Value

    least common multiple of self and n.

  • SwifterSwift: Ordinal representation of an integer.

       print((12).ordinalString()) // prints "12th"
    

    Declaration

    Swift

    @available(OSX 10.11, *)
    func ordinalString(locale: Locale = .current) -> String?

    Parameters

    locale

    locale, default is .current.

    Return Value

    string ordinal representation of number in specified locale language. E.g. input 92, output in “en”: “92nd”.