Arithmetic Functions

    Example:

    Arithmetic functions work for any pair of types from UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64, Float32, or Float64.

    Overflow is produced the same way as in C++.

    Calculates the sum of the numbers.
    You can also add integer numbers with a date or date and time. In the case of a date, adding an integer means adding the corresponding number of days. For a date with time, it means adding the corresponding number of seconds.

    minus(a, b), a - b operator

    You can also calculate integer numbers from a date or date with time. The idea is the same – see above for ‘plus’.

    multiply(a, b), a * b operator

    Calculates the product of the numbers.

    divide(a, b), a / b operator

    Calculates the quotient of the numbers. The result type is always a floating-point type.
    It is not integer division. For integer division, use the ‘intDiv’ function.
    When dividing by zero you get ‘inf’, ‘-inf’, or ‘nan’.

    Calculates the quotient of the numbers. Divides into integers, rounding down (by the absolute value).
    An exception is thrown when dividing by zero or when dividing a minimal negative number by minus one.

    intDivOrZero(a, b)

    modulo(a, b), a % b operator

    Calculates the remainder after division.
    If arguments are floating-point numbers, they are pre-converted to integers by dropping the decimal portion.
    The remainder is taken in the same sense as in C++. Truncated division is used for negative numbers.
    An exception is thrown when dividing by zero or when dividing a minimal negative number by minus one.

    moduloOrZero(a, b)

    Differs from modulo in that it returns zero when the divisor is zero.

    Calculates a number with the reverse sign. The result is always signed.

    abs(a)

    Calculates the absolute value of the number (a). That is, if a \< 0, it returns -a. For unsigned types it does not do anything. For signed integer types, it returns an unsigned number.

    gcd(a, b)

    lcm(a, b)

    Returns the least common multiple of the numbers.
    An exception is thrown when dividing by zero or when dividing a minimal negative number by minus one.