Tables

public class Tables

A class for developing Excel-like software / parser.

•  init() 

Undocumented

Declaration

Swift

public init()
•  dataSource 

Tables’ data source

Declaration

Swift

public var dataSource: TablesDataSource?
•  delegate 

Tables’ delegate

Declaration

Swift

public var delegate: TablesDelegate?
•  TablesError 

A type of error made for Tables

See more

Declaration

Swift

public enum TablesError : Error

Common Formulas + Trigonometry

•  ABS(_:) 

Absolute value of a number

Declaration

Swift

func ABS(_ number: BigNumber) -> BigNumber

Parameters

  number  A BigDouble
•  ACOS(_:) 

Arc-Cosinus of a number.

Declaration

Swift

func ACOS(_ number: BigNumber) throws -> BigNumber

Parameters

  number  Any BigDouble less than 2pi
•  ACOSH(_:) 

Hyperbolic Arc-Cosinus of a number.

Declaration

Swift

func ACOSH(_ number: BigNumber) throws -> BigNumber

Parameters

  number  Any BigDouble
•  ACOT(_:) 

Arc-Cotangent of a number.

Declaration

Swift

func ACOT(_ number: BigNumber) throws -> BigNumber

Parameters

  number  Any BigDouble less than 2pi
•  ACOTH(_:) 

Hyperbolic Arc-Cotangent of a number.

Declaration

Swift

func ACOTH(_ number: BigNumber) throws -> BigNumber

Parameters

  number  Any BigDouble

TODO: AGGREGATE + ARABIC

•  ASIN(_:) 

Arc-Sinus of a number.

Declaration

Swift

func ASIN(_ number: BigNumber) throws -> BigNumber

Parameters

  number  Any BigDouble less than 2pi
•  ASINH(_:) 

Hyperbolic Arc-Sinus of a number.

Declaration

Swift

func ASINH(_ number: BigNumber) throws -> BigNumber

Parameters

  number  Any BigDouble
•  ATAN(_:) 

Arc-Tangent of a number.

Declaration

Swift

func ATAN(_ number: BigNumber) throws -> BigNumber

Parameters

  number  Any BigDouble
•  ATAN2(_:_:) 

ATAN2(Y,X) returns the four-quadrant inverse tangent (tan-1) of Y and X, which must be real. The atan2 function follows the convention that atan2(x,x) returns 0 when x is mathematically zero (either 0 or -0).

Declaration

Swift

func ATAN2(_ n1: BigNumber, _ n2: BigNumber) throws -> BigNumber

Parameters

  n1  Y coordinate  n2  X coordinate
•  ATANH(_:) 

Hyperbolic Arc-Tangent of a number.

Declaration

Swift

func ATANH(_ number: BigNumber) throws -> BigNumber

Parameters

  number  Any BigDouble
•  BASE(_:_:) 

Convert number to any base

Declaration

Swift

func BASE(_ number: BigInt, _ radix: BigInt) -> String

Parameters

  number  The number you want to use  radix  The base / radix
•  CEILING(_:significance:mode:) 

Returns number rounded up, away from zero, to the nearest multiple of significance.

Declaration

Swift

func FLOOR(_ number: BigDouble, significance: BigDouble = 1, mode: Int = 0) throws -> BigDouble

Parameters

  number  The numeric value you want to round.  significance  The multiple to which you want to round.  mode  Either 0 or 1 (0 by default, ceiling). It will choose between flooring or ceiling the number if it’s negative.
•  GCD(_:) 

Returns the greatest common divisor of two or more integers.

The greatest common divisor is the largest integer that divides both number1 and number2 without a remainder.

Declaration

Swift

func GCD(_ n: BigInt...) throws -> BigInt

Parameters

  n  Number1 and 2 are required, subsequent numbers are optional. 1 to 255 values. If any value is not an integer, it is truncated.
•  GCD(array:) 

Returns the greatest common divisor of two or more integers.

The greatest common divisor is the largest integer that divides both number1 and number2 without a remainder.

Declaration

Swift

func GCD(array n: [BigInt]) throws -> BigInt

Parameters

  n  Number1 and 2 are required, subsequent numbers are optional. 1 to 255 values. If any value is not an integer, it is truncated.
•  INT(_:) 

Rounds a number down to the nearest integer.

Declaration

Swift

func INT(_ n: BigDouble) throws -> BigInt

Parameters

  n  The real number you want to round down to an integer.
•  LCM(_:) 

Returns the least common multiple of integers. The least common multiple is the smallest positive integer that is a multiple of all integer arguments number1, number2, and so on. Use LCM to add fractions with different denominators.

Declaration

Swift

func LCM(_ n: BigInt...) throws -> BigInt

Parameters

  n  Number1 and 2 are required, subsequent numbers are optional. 1 to 255 values. If any value is not an integer, it is truncated.
•  LCM(array:) 

Returns the least common multiple of integers. The least common multiple is the smallest positive integer that is a multiple of all integer arguments number1, number2, and so on. Use LCM to add fractions with different denominators.

Declaration

Swift

func LCM(array n: [BigInt]) throws -> BigInt

Parameters

  n  Number1 and 2 are required, subsequent numbers are optional. 1 to 255 values. If any value is not an integer, it is truncated.
•  LN(_:) 

Returns the natural logarithm of a number. Natural logarithms are based on the constant e (2.71828182845904)

LN is the inverse of the EXP function.

Declaration

Swift

func LN(_ n: BigDouble) -> BigDouble

Parameters

  n  The positive real number for which you want the natural logarithm.
•  LOG(_:base:) 

Returns the logarithm of a number to the base you specify.

Declaration

Swift

func LOG(_ n: BigDouble, base: BigDouble = 10) throws -> BigDouble

Parameters

  n  The positive real number for which you want the logarithm.  base  The base of the logarithm. If base is omitted, it is assumed to be 10.
•  LOG10(_:) 

Returns the logarithm base 10

Declaration

Swift

func LOG10(_ n: BigDouble) throws -> BigDouble

Parameters

  n  The positive real number for which you want the logarithm.

TODO MATRICES

•  MDETERM(_:) 

Returns the matrix determinant

Declaration

Swift

func MDETERM(_ lhs: Matrix) throws -> BigDouble

Parameters

  lhs  The Matrix you want to use.
•  MINVERSE(_:) 

The MINVERSE function returns the inverse matrix for a matrix stored in a Matrix object (Tables will convert that when using the parser).

Declaration

Swift

func MINVERSE(_ m: Matrix) -> Matrix

Parameters

  m  A numeric Matrix with an equal number of rows and columns.
•  MMULT(_:_:) 

The MMULT function returns the matrix product of two Matrix. The result is an array with the same number of rows as lhs and the same number of columns as rhs.

Declaration

Swift

func MMULT(_ lhs: Matrix, _ rhs: Matrix) -> Matrix

Parameters

  lhs  The Matrix you want to multiply.  rhs  The Matrix you want to multiply.
•  MROUND(_:_:) 

MROUND returns a number rounded to the desired multiple.

Declaration

Swift

func MROUND(_ n: BigDouble, _ m: BigDouble) throws -> BigDouble

Parameters

  n  The value to round.  m  The multiple to which you want to round number.
•  MOD(_:_:) 

Returns the remainder after number is divided by divisor.

The result has the same sign as divisor.

Declaration

Swift

func MOD(_ a: BigDouble, _ b: BigDouble) -> BigDouble

Parameters

  a  The number for which you want to find the remainder.  b  The number by which you want to divide number.
•  MULTINOMIAL(_:) 

Returns the ratio of the factorial of a sum of values to the product of factorials.

Declaration

Swift

func MULTINOMIAL(_ numbers: BigInt...) throws -> BigDouble

Parameters

  numbers  Number1 is required, subsequent numbers are optional. 1 to 255 values for which you want the multinomial.
•  MULTINOMIAL(array:) 

Returns the ratio of the factorial of a sum of values to the product of factorials.

Declaration

Swift

func MULTINOMIAL(array numbers: [BigInt]) throws -> BigDouble

Parameters

  numbers  Number1 is required, subsequent numbers are optional. 1 to 255 values for which you want the multinomial.
•  ODD(_:) 

Returns number rounded up to the nearest odd integer.

Regardless of the sign of number, a value is rounded up when adjusted away from zero. If number is an odd integer, no rounding occurs.

Declaration

Swift

func ODD(_ n: BigDouble) -> BigInt

Parameters

  n  The value to round.
•  PI() 

Returns the mathematical constant

Originally defined as the ratio of a circle’s circumference to its diameter, it now has various equivalent definitions and appears in many formulas in all areas of mathematics and physics. It is approximately equal to 3.14159. It has been represented by the Greek letter “π” since the mid-18th century, though it is also sometimes spelled out as “pi”. It is also called Archimedes’ constant.

Declaration

Swift

func PI() -> BigDouble
•  POWER(_:_:) 

Returns the result of a number raised to a power.

Let’s say you want to calculate an extremely small tolerance level for a machined part or the vast distance between two galaxies. To raise a number to a power, use the POWER function.

The “^” operator can be used instead of POWER to indicate to what power the base number is to be raised, such as in 5^2.

Declaration

Swift

func POWER(_ a: BigDouble, _ b: BigDouble) -> BigDouble

Parameters

  a  The base number. It can be any real number.  b  The exponent to which the base number is raised.
•  PRODUCT(_:) 

The PRODUCT function multiplies all the numbers given as arguments and returns the product. For example, if cells A1 and A2 contain numbers, you can use the formula =PRODUCT(A1, A2) to multiply those two numbers together. You can also perform the same operation by using the multiply (*) mathematical operator; for example, =A1 * A2. The PRODUCT function is useful when you need to multiply many cells together. For example, the formula =PRODUCT(A1:A3, C1:C3) is equivalent to =A1 * A2 * A3 * C1 * C2 * C3.

Declaration

Swift

func PRODUCT(_ ns: BigDouble...) -> BigDouble

Parameters

  ns  The first number or range that you want to multiply. Continue by adding additional numbers or ranges that you want to multiply, up to a maximum of 255 arguments.
•  PRODUCT(_:) 

The PRODUCT function multiplies all the numbers given as arguments and returns the product. For example, if cells A1 and A2 contain numbers, you can use the formula =PRODUCT(A1, A2) to multiply those two numbers together. You can also perform the same operation by using the multiply (*) mathematical operator; for example, =A1 * A2. The PRODUCT function is useful when you need to multiply many cells together. For example, the formula =PRODUCT(A1:A3, C1:C3) is equivalent to =A1 * A2 * A3 * C1 * C2 * C3.

Declaration

Swift

func PRODUCT(_ ns: [BigDouble]) -> BigDouble

Parameters

  ns  The first number or range that you want to multiply. Continue by adding additional numbers or ranges that you want to multiply, up to a maximum of 255 arguments.
•  QUOTIENT(_:_:) 

Returns the integer portion of a division. Use this function when you want to discard the remainder of a division.

Tip: If you want to divide numeric values, you should use the “/” operator as there isn’t a DIVIDE function in Euler.Tables. For example, to divide 5 by 2, you would type =5/2 into a cell, which returns 2.5. The QUOTIENT function for these same numbers =QUOTIENT(5,2) returns 2, since QUOTIENT doesn’t return a remainder.

Declaration

Swift

func QUOTIENT(_ numerator: BigDouble, _ denominator: BigDouble) throws -> BigInt

Parameters

  numerator  The dividend.  denominator  The divisor.
•  RADIANS(_:) 

Declaration

Swift

func RADIANS(_ angle: BigDouble) -> BigDouble

Parameters

  angle  An angle in degrees that you want to convert.
•  RAND() 

RAND returns an evenly distributed random real number greater than or equal to 0 and less than 1.

A new random real number is returned every time the worksheet is calculated.

Declaration

Swift

func RAND() -> BigDouble
•  RANDBETWEEN(_:_:) 

Returns a random integer number between the numbers you specify. A new random integer number is returned every time the worksheet is calculated.

Declaration

Swift

func RANDBETWEEN(_ a: BigDouble, _ b: BigDouble) -> BigDouble

Parameters

  a  The smallest integer RANDBETWEEN will return.  b  The largest integer RANDBETWEEN will return.

Todo Roman

•  ROUND(_:digits:) 

The ROUND function rounds a number to a specified number of digits.

For example, if cell A1 contains 23.7825, and you want to round that value to two decimal places, you can use the following formula:

=ROUND(A1, 2) The result of this function is 23.78.

• If digits is greater than 0 (zero), then number is rounded to the specified number of decimal places.
• If digits is 0, the number is rounded to the nearest integer.
• If digits is less than 0, the number is rounded to the left of the decimal point.
• To always round up (away from zero), use the ROUNDUP function.
• To always round down (toward zero), use the ROUNDDOWN function.
• To round a number to a specific multiple (for example, to round to the nearest 0.5), use the MROUND function.

Declaration

Swift

func ROUND(_ n: BigDouble, digits: BigInt) -> BigDouble

Parameters

  n  The number that you want to round.  digits  The number of digits to which you want to round the number argument.
•  ROUNDDOWN(_:digits:) 

Rounds a number down, toward zero.

Declaration

Swift

func ROUNDDOWN(_ n: BigDouble, digits: BigInt) -> BigDouble

Parameters

  n  Any real number that you want rounded down.  digits  The number of digits to which you want to round number.
•  ROUNDUP(_:digits:) 

Rounds a number up, away from zero.

Declaration

Swift

func ROUNDUP(_ n: BigDouble, digits: BigInt) -> BigDouble

Parameters

  n  Any real number that you want rounded up.  digits  The number of digits to which you want to round number.
•  SEC(_:) 

Returns the secant of an angle.

Declaration

Swift

func SEC(_ n: BigDouble) throws -> BigDouble

Parameters

  n  Number is the angle in radians for which you want the secant.
•  SECH(_:) 

Returns the hyperbolic secant of an angle.

Declaration

Swift

func SECH(_ n: BigDouble) -> BigDouble

Parameters

  n  Number is the angle in radians for which you want the hyperbolic secant.
•  SERIESSUM(_:_:_:_:) 

Many functions can be approximated by a power series expansion. Returns the sum of a power series based on the formula:

SERIES(x, n, m, a)=a_1x^n+a_2x^{n+m}+…+a_ix^{n+(i-1)m}

Declaration

Swift

func SERIESSUM(_ x: BigDouble, _ n: BigDouble, _ m: BigDouble, _ coefficients: BigDouble...) throws -> BigDouble

Parameters

  x  The input value to the power series.  n  The initial power to which you want to raise x.  m  The step by which to increase n for each term in the series.  coefficients  A set of coefficients by which each successive power of x is multiplied. The number of values in coefficients determines the number of terms in the power series. For example, if there are three values in coefficients, then there will be three terms in the power series.
•  SERIESSUM(_:_:_:_:) 

Many functions can be approximated by a power series expansion. Returns the sum of a power series based on the formula:

SERIES(x, n, m, a)=a_1x^n+a_2x^{n+m}+…+a_ix^{n+(i-1)m}

Declaration

Swift

func SERIESSUM(_ x: BigDouble, _ n: BigDouble, _ m: BigDouble, _ coefficients: [BigDouble]) throws -> BigDouble

Parameters

  x  The input value to the power series.  n  The initial power to which you want to raise x.  m  The step by which to increase n for each term in the series.  coefficients  A set of coefficients by which each successive power of x is multiplied. The number of values in coefficients determines the number of terms in the power series. For example, if there are three values in coefficients, then there will be three terms in the power series.
•  SIGN(_:) 

Determines the sign of a number. Returns 1 if the number is positive, zero (0) if the number is 0, and -1 if the number is negative.

Declaration

Swift

func SIGN(_ n: BigDouble) -> BigInt

Parameters

  n  Any real number.
•  SIN(_:) 

Sinus function

Declaration

Swift

func SIN(_ n: BigDouble) throws -> BigDouble

Parameters

  n  Any real less than 2pi
•  SINH(_:) 

Hyperbolic sinus function

Declaration

Swift

func SINH(_ n: BigDouble) -> BigDouble

Parameters

  n  Any real
•  SQRT(_:) 

Returns a positive square root.

Declaration

Swift

func SQRT(_ n: BigDouble) throws -> BigDouble

Parameters

  n  The number for which you want the square root.
•  ROOT(_:_:) 

Returns a positive nth root.

Declaration

Swift

func ROOT(_ n: BigDouble, _ base: Int) throws -> BigDouble

Parameters

  n  The number for which you want the square root.  base  The nth root (ex: 2, 3,…).
•  SQRTPI(_:) 

Returns the square root of (number * pi).

Declaration

Swift

func SQRTPI(_ n: BigDouble) throws -> BigDouble

Parameters

  n  The number by which pi is multiplied.

Todo: SUBTOTAL

•  ADD(_:_:) 

Declaration

Swift

func ADD(_ a: BigDouble, _ b: BigDouble) -> BigDouble

Parameters

  a  Any real  b  Any real
•  MINUS(_:_:) 

Substract 2 numbers

Declaration

Swift

func MINUS(_ a: BigDouble, _ b: BigDouble) -> BigDouble

Parameters

  a  Any real  b  Any real
•  DIVIDE(_:_:) 

Divide 2 numbers

Declaration

Swift

func DIVIDE(_ a: BigDouble, _ b: BigDouble) throws -> BigDouble

Parameters

  a  Any real  b  Any real
•  MULTIPLY(_:_:) 

Multiply 2 numbers

Declaration

Swift

func MULTIPLY(_ a: BigDouble, _ b: BigDouble) -> BigDouble

Parameters

  a  Any real  b  Any real
•  GTE(_:_:) 

Greater than or equal (>=)

Declaration

Swift

func GTE(_ a: BigDouble, _ b: BigDouble) -> Bool
•  LT(_:_:) 

Less than (<)

Declaration

Swift

func LT(_ a: BigDouble, _ b: BigDouble) -> Bool
•  LTE(_:_:) 

Less than or equal (<=)

Declaration

Swift

func LTE(_ a: BigDouble, _ b: BigDouble) -> Bool
•  EQ(_:_:) 

Equal (==)

Declaration

Swift

func EQ(_ a: BigDouble, _ b: BigDouble) -> Bool
•  NE(_:_:) 

Not equal (==)

Declaration

Swift

func NE(_ a: BigDouble, _ b: BigDouble) -> Bool
•  POW(_:_:) 

Returns the result of a number raised to a power. Same as POWER

Let’s say you want to calculate an extremely small tolerance level for a machined part or the vast distance between two galaxies. To raise a number to a power, use the POWER function.

The “^” operator can be used instead of POWER to indicate to what power the base number is to be raised, such as in 5^2.

Declaration

Swift

func POW(_ a: BigDouble, _ b: BigDouble) -> BigDouble

Parameters

  a  The base number. It can be any real number.  b  The exponent to which the base number is raised.
•  SUM(_:) 

Declaration

Swift

func SUM(_ n: BigDouble...) -> BigDouble

Parameters

  n  The numbers you want to sum
•  SUM(_:) 

Declaration

Swift

func SUM(_ n: [BigDouble]) -> BigDouble

Parameters

  n  The numbers you want to sum

TODO: SUMIF(s)

•  SUMPRODUCT(_:) 

The SUMPRODUCT function returns the sum of the products of corresponding ranges or arrays.

Example: SUMPRODUCT([1, 2, 3], [2, 3, 4]) //= 20

Declaration

Swift

func SUMPRODUCT(_ a: [BigDouble]...) throws -> BigDouble

Parameters

  a  An array of numbers
•  SUMPRODUCT(_:) 

The SUMPRODUCT function returns the sum of the products of corresponding ranges or arrays.

Example: SUMPRODUCT([1, 2, 3], [2, 3, 4]) //= 20

Declaration

Swift

func SUMPRODUCT(_ a: [[BigDouble]]) throws -> BigDouble

Parameters

  a  An array of numbers
•  SUMSQ(_:) 

Returns the sum of the squares of the arguments.

Declaration

Swift

func SUMSQ(_ n: BigDouble...) -> BigDouble

Parameters

  n  The numbers you want to square and sum
•  SUMSQ(_:) 

Returns the sum of the squares of the arguments.

Declaration

Swift

func SUMSQ(_ n: [BigDouble]) -> BigDouble

Parameters

  n  The numbers you want to square and sum
•  SUMX2MY2(_:_:) 

Returns the sum of the difference of squares of corresponding values in two arrays.

Declaration

Swift

func SUMX2MY2(_ a1: [BigDouble], _ a2: [BigDouble]) throws -> BigDouble

Parameters

  a1  List of number  a2  List of number
•  SUMX2PY2(_:_:) 

Returns the sum of the sum of squares of corresponding values in two arrays. The sum of the sum of squares is a common term in many statistical calculations.

Declaration

Swift

func SUMX2PY2(_ a1: [BigDouble], _ a2: [BigDouble]) throws -> BigDouble

Parameters

  a1  List of number  a2  List of number
•  SUMXMY2(_:_:) 

Returns the sum of squares of differences of corresponding values in two arrays.

Declaration

Swift

func SUMXMY2(_ a1: [BigDouble], _ a2: [BigDouble]) throws -> BigDouble

Parameters

  a1  List of number  a2  List of number
•  TAN(_:) 

Tangent of a number.

Declaration

Swift

func TAN(_ number: BigNumber) throws -> BigNumber

Parameters

  number  Any BigDouble less than 2pi
•  TANH(_:) 

Hyperbolic Tangent of a number.

Declaration

Swift

func TANH(_ number: BigNumber) throws -> BigNumber

Parameters

  number  Any BigDouble
•  TRUNC(_:_:) 

Truncates a number to an integer by removing the fractional part of the number.

Declaration

Swift

func TRUNC(_ number: BigDouble, _ digits: Int = 0) -> BigDouble

Parameters

  number  The number you want to truncate.  digits  Optional. A number specifying the precision of the truncation.

Date & Time

•  DATE(_:_:_:) 

The DATE function returns the sequential serial number that represents a particular date.

Declaration

Swift

func DATE(_ year: Int, _ month: Int, _ day: Int) throws -> BigDouble

Parameters

  year  The year of your date  month  The month of your date  day  The day of your date

Return Value

Serial Date

•  DATEVALUE(_:) 

The DATEVALUE function converts a date that is stored as text to a serial number.

For example, the formula =DATEVALUE(“1/1/2008”) returns 39448, the serial number of the date 1/1/2008. Remember, though, that your computer’s system date setting may cause the results of a DATEVALUE function to vary from this example The DATEVALUE function is helpful in cases where a worksheet contains dates in a text format that you want to filter, sort, or format as dates, or use in date calculations.

Declaration

Swift

func DATEVALUE(_ str: String) throws -> BigDouble

Parameters

  str  Text that represents a date in an Euler date format, or a reference to a cell that contains text that represents a date in an Euler date format. For example, “1/30/2008” is a text string within quotation marks that represent a date.

Return Value

Serial Date

•  YEARFRAC(start:end:basis:) 

YEARFRAC calculates the fraction of the year represented by the number of whole days between two dates (the start and the end).

For instance, you can use YEARFRAC to identify the proportion of a whole year’s benefits, or obligations to assign to a specific term.

Declaration

Swift

func YEARFRAC(start: BigDouble, end: BigDouble, basis: Int = 0) throws -> BigDouble

Parameters

  start  A date that represents the start date.  end  A date that represents the end date.  basis  The type of day count basis to use.

Return Value

The proportion of the year

•  BIN2DEC(_:) 

Converts a binary number to decimal.

Throws

If number isn’t composed of 1s or 0s, the function will fail

Declaration

Swift

func BIN2DEC(_ number: BigDouble) throws -> BigDouble

Parameters

  number  Input number to be converted (has to be composed of 1s and 0s)

Return Value

The converted number

•  BIN2HEX(_:) 

Converts a binary number to hexadecimal.

Throws

If number isn’t composed of 1s or 0s, the function will fail

Declaration

Swift

func BIN2HEX(_ number: BigDouble) throws -> String

Parameters

  number  Input number to be converted (has to be composed of 1s and 0s)

Return Value

The converted number

•  BIN2OCT(_:) 

Converts a binary number to octal.

Throws

If number isn’t composed of 1s or 0s, the function will fail

Declaration

Swift

func BIN2OCT(_ number: BigDouble) throws -> BigDouble

Parameters

  number  Input number to be converted (has to be composed of 1s and 0s)

Return Value

The converted number

•  BITAND(_:_:) 

Returns a bitwise ‘AND’ of two numbers.

Declaration

Swift

func BITAND(_ lhs: BigInt, _ rhs: BigInt) -> BigInt
•  BITOR(_:_:) 

Returns a bitwise ‘OR’ of two numbers.

Declaration

Swift

func BITOR(_ lhs: BigInt, _ rhs: BigInt) -> BigInt
•  BITXOR(_:_:) 

Returns a bitwise ‘XOR’ of two numbers.

Declaration

Swift

func BITXOR(_ lhs: BigInt, _ rhs: BigInt) -> BigInt
•  BITLSHIFT(_:_:) 

Returns a number shifted left by the specified number of bits.

Declaration

Swift

func BITLSHIFT(_ n: BigInt, _ amount: BigInt) -> BigInt

Parameters

  n  Number must be an integer greater than or equal to 0.  amount  Shift amount

Return Value

Number shifted to the left

•  BITRSHIFT(_:_:) 

Returns a number shifted right by the specified number of bits.

Declaration

Swift

func BITRSHIFT(_ n: BigInt, _ amount: BigInt) -> BigInt

Parameters

  n  Number must be an integer greater than or equal to 0.  amount  Shift amount

Return Value

Number shifted to the right

•  CONVERT(_:from_unit:to_unit:) 

Converts a number from one measurement system to another. For example, CONVERT can translate a table of distances in miles to a table of distances in kilometers.

Declaration

Swift

func CONVERT(_ n: BigDouble, from_unit: String, to_unit: String) throws -> BigDouble

Parameters

  n  It is the value in from_unit units to convert.  from_unit  It is the units for number.  to_unit  The units for the result.
•  DEC2BIN(_:) 

Converts a decimal number to binary.

Declaration

Swift

func DEC2BIN(_ number: BigDouble) -> BigDouble

Parameters

  number  Input number to be converted

Return Value

The converted number

•  DEC2HEX(_:) 

Converts a decimal number to hexadecimal.

Declaration

Swift

func DEC2HEX(_ number: BigDouble) -> String

Parameters

  number  Input number to be converted

Return Value

The converted number

•  DEC2OCT(_:) 

Converts a decimal number to octal.

Declaration

Swift

func DEC2OCT(_ number: BigDouble) -> BigDouble

Parameters

  number  Input number to be converted

Return Value

The converted number

•  DELTA(_:_:) 

Tests whether two values are equal. Returns 1 if number1 = number2; returns 0 otherwise. Use this function to filter a set of values. For example, by summing several DELTA functions you calculate the count of equal pairs. This function is also known as the Kronecker Delta function.

Declaration

Swift

func DELTA(_ number1: BigDouble, _ number2: BigDouble) -> Int

Parameters

  number1  Any number  number2  Any number

Return Value

Returns 1 if number1 = number2; returns 0 otherwise

Todo: Error functions

•  HEX2BIN(_:) 

Converts an hexadecimal number to binary

Declaration

Swift

func HEX2BIN(_ str: String) throws -> BigInt

Parameters

  number  Input number to be converted

Return Value

The converted number

•  HEX2DEC(_:) 

Converts an hexadecimal number to decimal

Declaration

Swift

func HEX2DEC(_ str: String) throws -> BigInt

Parameters

  number  Input number to be converted

Return Value

The converted number

•  HEX2OCT(_:) 

Converts an hexadecimal number to octal

Declaration

Swift

func HEX2OCT(_ str: String) throws -> BigInt

Parameters

  number  Input number to be converted

Return Value

The converted number

Financial functions

•  ACCRINT(_:_:_:_:_:_:_:) 

Returns the accrued interest for a security that pays periodic interest.

Throws

TablesError

Declaration

Swift

func ACCRINT(_ issue: Int, _ first: Int, _ settlement: Int, _ rate: BigDouble, _ par: BigDouble = 1000, _ frequency: Int = 1, _ basis: Int = 0) throws -> BigDouble

Parameters

  issue  The security’s issue date.  first  The security’s first interest date.  settlement  The security’s settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.  rate  The security’s annual coupon rate.  par  The security’s par value. If you omit par, ACCRINT uses \$1,000.  frequency  The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.  basis  The type of day count basis to use.

Return Value

Accrued interest for a security that pays periodic interest

Logical operators

•  AND(_:) 

AND operator.

If argument list contains a false statement, it returns false, otherwise it returns true

Declaration

Swift

func AND(_ b: Bool...) -> Bool
•  AND(_:) 

AND operator.

If argument list contains a false statement, it returns false, otherwise it returns true

Declaration

Swift

func AND(_ b: [Bool]) -> Bool
•  CHOOSE(_:_:) 

Use CHOOSE to select one of up to 256 values based on the index number.

For example, if value1 through value7 are the days of the week, CHOOSE returns one of the days when a number between 1 and 7 is used as i.

Declaration

Swift

func CHOOSE<T>(_ i: Int, _ b: T...) throws -> T

Parameters

  i  Specifies which value argument is selected.  b  1 to 254 value arguments from which CHOOSE selects a value or an action to perform based on index.
•  CHOOSE(_:_:) 

Use CHOOSE to select one of up to 256 values based on the index number.

For example, if value1 through value7 are the days of the week, CHOOSE returns one of the days when a number between 1 and 7 is used as i.

Declaration

Swift

func CHOOSE<T>(_ i: Int, _ b: [T]) throws -> T

Parameters

  i  Specifies which value argument is selected.  b  1 to 254 value arguments from which CHOOSE selects a value or an action to perform based on index.
•  IF(_:_:_:) 

The IF function allows you to make a logical comparison between a value and what you expect by testing for a condition and returning a result if that condition is True or False.

Declaration

Swift

func IF<T>(_ c: Bool, _ a: T, _ b: T) -> T

Parameters

  c  Condition  a  Value to return if c is true  b  Value to return if c is false
•  OR(_:) 

OR operator.

If argument list contains at least one true statement, it returns true, otherwise it returns false

Declaration

Swift

func OR(_ b: Bool...) -> Bool
•  OR(_:) 

OR operator.

If argument list contains at least one true statement, it returns true, otherwise it returns false

Declaration

Swift

func OR(_ b: [Bool]) -> Bool
•  XOR(_:) 

The XOR function returns a logical Exclusive Or of all arguments.

Declaration

Swift

func XOR(_ b: Bool...) -> Bool

Parameters

  b  Conditions
•  XOR(_:) 

The XOR function returns a logical Exclusive Or of all arguments.

Declaration

Swift

func XOR(_ b: [Bool]) -> Bool

Parameters

  b  Conditions

Statistical functions

•  AVEDEV(_:) 

Returns the average of the absolute deviations of data points from their mean. AVEDEV is a measure of the variability in a data set.

Declaration

Swift

func AVEDEV(_ array: [BigDouble]) -> BigDouble
•  AVERAGE(_:) 

Returns the average (arithmetic mean) of the arguments. For example, if the range A1:A20 contains numbers, the formula =AVERAGE(A1:A20) returns the average of those numbers.

Declaration

Swift

func AVERAGE(_ array: [BigDouble]) -> BigDouble
•  CORREL(_:_:) 

The CORREL function returns the correlation coefficient of two arrays. Use the correlation coefficient to determine the relationship between two properties. For example, you can examine the relationship between a location’s average temperature and the use of air conditioners.

Declaration

Swift

func CORREL(_ array1: [BigDouble], _ array2: [BigDouble]) throws -> BigDouble

Parameters

  array1  A an array of values  array2  A an array of values

Return Value

Correlation coefficient of two arrays

•  COUNT(_:) 

Counts the element of the given array

Declaration

Swift

func COUNT(_ array: [Any]) -> Int

Parameters

  array  Any array composed of random elements

Return Value

Counted value

•  COUNTUNIQUE(_:) 

Counts the unique element of the given array

Declaration

Swift

func COUNTUNIQUE(_ array: [AnyHashable]) -> Int

Parameters

  array  Any array composed of random Hashable elements

Return Value

Counted value

•  DEVSQ(_:) 

Returns the sum of squares of deviations of data points from their sample mean.

Declaration

Swift

func DEVSQ(_ array: [BigDouble]) -> BigDouble
•  FISHER(_:) 

Returns the Fisher transformation at x. This transformation produces a function that is normally distributed rather than skewed. Use this function to perform hypothesis testing on the correlation coefficient.

Declaration

Swift

func FISHER(_ x: BigDouble) -> BigDouble
•  FISHERINV(_:) 

Returns the inverse of the Fisher transformation. Use this transformation when analyzing correlations between ranges or arrays of data. If y = FISHER(x), then FISHERINV(y) = x.

Declaration

Swift

func FISHERINV(_ y: BigDouble) -> BigDouble
•  GAMMA(_:) 

The gamma function (represented by \Gamma, the capital letter gamma from the Greek alphabet) is one commonly used extension of the factorial function to complex numbers. The gamma function is defined for all complex numbers except the non-positive integers. For any positive integer n: \Gamma (n)=(n-1)!

Declaration

Swift

func GAMMA(_ x: BigDouble) throws -> BigDouble

Parameters

  x  Any number

Return Value

The gamma function value.

•  GAMMALN(_:) 

Returns the natural logarithm of the gamma function, \Gamma (x).

Declaration

Swift

func GAMMALN(_ x: BigDouble) throws -> BigDouble

Parameters

  x  Any number
•  GAUSS(_:) 

Integral of the Gauss function

Computed using:

\int_{0}^{x}\frac{1}{\sqrt{2\pi}}*e^{-\frac{x^{2}}{2}}dx = \frac{1}{2}\cdot \operatorname{erf}\left( \frac{x}{\sqrt{2}} \right)

Declaration

Swift

func GAUSS(_ x: BigDouble) -> BigDouble

Parameters

  x  Any number
•  GEOMEAN(_:) 

Returns the geometric mean.

In mathematics, the geometric mean is a mean or average, which indicates the central tendency or typical value of a set of numbers by using the product of their values (as opposed to the arithmetic mean which uses their sum). The geometric mean is defined as the nth root of the product of n numbers, i.e., for a set of numbers x_1, x_2, …, x_n, the geometric mean is defined as

\left(\prod_{i=1}^n x_i\right)^\frac{1}{n} = \sqrt[n]{x_1 x_2 \cdots x_n}

Declaration

Swift

func GEOMEAN(_ array: [BigDouble]) -> BigDouble
•  HARMEAN(_:) 

Returns the harmonic mean

In mathematics, the harmonic mean (sometimes called the subcontrary mean) is one of several kinds of average, and in particular, one of the Pythagorean means. Typically, it is appropriate for situations when the average of rates is desired.

The harmonic mean can be expressed as the reciprocal of the arithmetic mean of the reciprocals of the given set of observations. As a simple example, the harmonic mean of 1, 4, and 4 is

\left(\frac{1^{-1} + 4^{-1} + 4^{-1}}{3}\right)^{-1} = \frac{3}{\frac{1}{1} + \frac{1}{4} + \frac{1}{4}} = \frac{3}{1.5} = 2

Declaration

Swift

func HARMEAN(_ array: [BigDouble]) -> BigDouble
•  KURT(_:) 

Returns the kurtosis of a data set. Kurtosis characterizes the relative peakedness or flatness of a distribution compared with the normal distribution. Positive kurtosis indicates a relatively peaked distribution. Negative kurtosis indicates a relatively flat distribution.

Declaration

Swift

func KURT(_ array: [BigDouble]) -> BigDouble
•  MAX(_:) 

Returns the maximum element in the sequence.

Declaration

Swift

func MAX(_ array: [BigDouble]) -> BigDouble?

Parameters

  array  Any BigDouble array

Return Value

The sequence’s maximum element. If the sequence has no elements, returns nil.

•  MEDIAN(_:) 

The median is the number in the middle of a set of numbers.

If there is an even number of numbers in the set, then MEDIAN calculates the average of the two numbers in the middle.

Declaration

Swift

func MEDIAN(_ array: [BigDouble]) -> BigDouble

Parameters

  array  Any BigDouble array

Return Value

The median of the given numbers.

•  MIN(_:) 

Returns the minimum element in the sequence.

Declaration

Swift

func MIN(_ array: [BigDouble]) -> BigDouble?

Parameters

  array  Any BigDouble array

Return Value

The sequence’s minimum element. If the sequence has no elements, returns nil.

•  PERMUT(_:_:) 

Returns the number of permutations for a given number of objects that can be selected from number objects.

A permutation is any set or subset of objects or events where internal order is significant. Permutations are different from combinations, for which the internal order is not significant. Use this function for lottery-style probability calculations.

Declaration

Swift

func PERMUT(_ number: Int, _ numberChosen: Int) throws -> BigInt

Parameters

  number  An integer that describes the number of objects.  numberChosen  An integer that describes the number of objects in each permutation.
•  PHI(_:) 

Phi function

Declaration

Swift

func PHI(_ x: BigDouble) -> BigDouble

Parameters

  x  the number for which you want the density of the standard normal distribution.

Return Value

the value of the density function for a standard normal distribution.

•  PERCENTILE(_:percent:) 

Returns the k-th percentile of values in a range. You can use this function to establish a threshold of acceptance. For example, you can decide to examine candidates who score above the 90th percentile.

Declaration

Swift

func PERCENTILE(_ array: [BigDouble], percent: Double) throws -> BigDouble

Parameters

  array  The array or range of data that defines relative standing.  percent  The percentile value in the range 0..1, exclusive.
•  SKEW(_:) 

Returns the skewness of a distribution. Skewness characterizes the degree of asymmetry of a distribution around its mean. Positive skewness indicates a distribution with an asymmetric tail extending toward more positive values. Negative skewness indicates a distribution with an asymmetric tail extending toward more negative values.

Declaration

Swift

func SKEW(_ array: [BigDouble]) -> BigDouble
•  STANDARDIZE(_:_:_:) 

Returns a normalized value from a distribution characterized by mean and standard deviation.

Declaration

Swift

func STANDARDIZE(_ x: BigDouble, _ mean: BigDouble, _ sd: BigDouble) -> BigDouble

Parameters

  x  The value you want to normalize  mean  The arithmetic mean of the distribution  sd  The standard deviation of the distribution
•  STDEV(_:) 

Returns the standard deviation of the list

The standard deviation (SD, also represented by the lower case Greek letter sigma σ for the population standard deviation or the Latin letter s for the sample standard deviation) is a measure of the amount of variation or dispersion of a set of values. A low standard deviation indicates that the values tend to be close to the mean (also called the expected value) of the set, while a high standard deviation indicates that the values are spread out over a wider range.

Computed using:

\sigma = \sqrt{\frac{\sum_{}^{}(x-\bar{x})^2}{n-1}}

Declaration

Swift

func STDEV(_ array: [BigDouble]) -> BigDouble
•  VAR(_:) 

Returns the variance of the list

In probability theory and statistics, variance is the expectation of the squared deviation of a random variable from its mean. Informally, it measures how far a set of (random) numbers are spread out from their average value.

Computed using:

V = \sigma^2 = \frac{\sum_{}^{}(x-\bar{x})^2}{n-1}

Declaration

Swift

func VAR(_ array: [BigDouble]) -> BigDouble
•  interpret(command:) 

Interprets the given command

Declaration

Swift

func interpret(command: String) throws -> CellValue

Parameters

  command  The command you want to execute. Example: =SUM(1, 2, 3, 4)
•  functions 

Huge list of all Tables functions.

While this is public, it’s not intended for use.

Declaration

Swift

static var functions: [String : (([CellValue]) throws -> CellValue)] { get }
•  commonFormulas 

Common Formulas Functions (for parser)

Declaration

Swift

var commonFormulas: [String : (([CellValue]) throws -> CellValue)] { get }
•  dateFormulas 

Date/Time related Formulas Functions (for parser)

Declaration

Swift

var dateFormulas: [String : (([CellValue]) throws -> CellValue)] { get }
•  engineeringFormulas 

Engineering Formulas Functions (for parser)

Declaration

Swift

var engineeringFormulas: [String : (([CellValue]) throws -> CellValue)] { get }
•  financialFormulas 

Financial Formulas Functions (for parser)

Declaration

Swift

var financialFormulas: [String : (([CellValue]) throws -> CellValue)] { get }
•  logicalFormulas 

Logical Formulas Functions (for parser)

Declaration

Swift

var logicalFormulas: [String : (([CellValue]) throws -> CellValue)] { get }
•  statsFormulas 

Statistical Formulas Functions (for parser)

Declaration

Swift

var statsFormulas: [String : (([CellValue]) throws -> CellValue)] { get }