## Calculations

#### Date and time arithmetic

Date values and calculations are supported in Blockpad formulas.

##### Enter a date

To enter a date in a formula, yyyy.mm.dd is the basic syntax. However, the month or day can be typed in as one digit.

For example, the date January 3rd, 1892 is typed in as 1892.01.03 . You can also enter a date using the Date() function. Our example above would be Date(1892,1,3). ##### Enter a date and time of day

You can type in a date and time, where yyyy.mm.dd.hh.mm.ss is the syntax. With this, military time must be used for p.m. times.

Seconds, minutes, or hours can be left off the end, but year, month, and date must all be specified. Otherwise, Blockpad will see a regular number with a decimal. ##### Date and time calculations

You can perform basic calculations with date values and numbers with time units. So, a date value subtracted from a date value gives a time number. Also, a time number added to or subtracted from a date value gives a date value. #### Logic and Boolean values The main difference between normal spreadsheets is that two equals signs are used to test equality. Other than that, it's the same.

• == equal to
• != not equal to
• < less than
• > greater than
• <= less than/equal to
• >= greater than/equal to

You can reference values like normal, and use logic functions like if(). You can also type Boolean values (true or false) directly into a formula. If multiple tests are used in a row, then all of them must be true separately to yield true. This is the same as using the And() function on each test separately. #### Matrices and arrays

Blockpad dynamic equations support arrays and matrices. Many of the built-in functions are matrix compatible as well. ##### Enter an array or matrix

To create an array in a formula, brackets are used. Brackets ([ ]) specify the start and end of the array. Commas (,) separate members of one row into columns, and semi-colons (;) specify the end of a row. For example, [11, 22, 33; 22, 33, 11; 33, 11, 22] typed into a formula produces the matrix below.

In Blockpad, arrays and references to groups of cells are treated the same. So, arrays can be created by referencing a group of cells from a spreadsheet or table. In this case, the array will update with the table.

##### Array names

Array values can have names, just like normal number and text values. ##### Matrix calculations

To add, subtract, divide, and multiply matrices, the normal operators are used (+, -, /, *). To find the inverse of a matrix, you can raise it to negative one (^-1) or use the inverse function. If a matrix calculation can't be completed, then you will get an error. Matrices also support units and unit tracking Functions work with arrays too. Some treat the array like a group of spreadsheet cells. And some treat the array as a matrix. ##### Arrays - more than just numbers

Arrays can have any type of values: text, numbers, even more arrays - anything that can go in a spreadsheet cell and a little more. A useful application is to use lookup functions with arrays, just like using them with a spreadsheet. Arrays can be displayed in a spreadsheet too.

###### Make an array formula:
1. Type in a formula that results in an array.
2. Press ctrl+shift+enter instead of enter to complete the formula.

Now when you try to edit any cell in the array, you are prompted to edit the array formula. However, you can still reference the cells like normal.

If there are non-empty cells that an array formula tries to fill, then the formula still runs, but a red line appears to let you know it didn't fill all of the cells. ##### Array parentheses lookup

You can reference the values inside of an array using parentheses after the array name. The basic synax is ArrayName(RowNumber, ColumnNumber). If you give just one number in the parentheses, then it specifies a row. You can specify a column by typing an asterisk for the row. This works to specify just a row too, just put an asterisk for the column. ##### Complex numbers

Blockpad supports complex numbers in a very simple way. Simply use the letter i to denote the imaginary number inside of a formula/dynamic equation. The square root of a negative number will also produce i. 