# Catext Help


In this reference manual you will find detailed information on every aspect of Catext. If there is no answer for your question here, feel free to send an email.


## General Syntax


There are three types of elements in Catext: expressions, text and comments. Basically, anything that's not text or a comment is an expression.


## Expressions


Expressions define operations to perform on numbers, the result of which is then calculated by Catext. The basic building block of expressions are numbers:


1 // integer

1.2 // decimal fraction

1.2e3 // exponential notation


Catext supports the standard basic set of arithmetic operations:


1 + 2 = 3 // addition

3 − 1 = 2 // subtraction

2 × 3 = 6 // multiplication

3 / 2 = 1.5 // division


Parentheses can be used to change the default order of operations:


2 × (1 + 3) = 8


The basic set is extended with the following operations:


2 % 3 = 2 // modulo/remainder

3^2 = 9 // exponentiation/power


If you are facing an ambiguity between `%` used as an operator and as a percent sign, pad `%` with spaces to make it behave like an operator: {1% + 1} vs {1 % +1}.


Exponentiation is right-associative: {4^3^2} means {4^(3^2)}.


### Percentages


Catext supports the following basic percentage operations:


200 + 10% = 220 // 10% more

200 − 10% = 180 // 10% less

200 × 10% = 20 // 10% of 200


10% + 20% = 30% // addition

10% − 20% = −10% // subtraction

10% / 2 = 5% // division

10% × 2 = 20% // multiplication


More advanced percentage operations are also supported:


// compound percentage

10% × −5% = 4.5%

200 × (10% × −5%) = 9


// effective annual percentage

(10% / 12)^12 = 10.471%

1 000 + (10% / 12)^(5 × 12) = 1 645.309


### Constants and Functions


The following built-in constants and functions are supported:


π = 3.142 // `pi`

e = 2.718 // Euler's number


abs(−1) = 1 // absolute value


round(π) = 3 // round to nearest

floor(π) = 3 // round down

ceil(π) = 4 // round up

int(π) = 3 // integer part

frac(π) = 0.142 // fractional part


ln(e) = 1 // natural logarithm

log(e) = 1

lg(100) = 2 // base 10

log₁₀(100) = 2 // `log10(100)`

lb(8) = 3 // base 2

log₂(8) = 3 // `log10(8)`


sin(π / 2) = 1 // sine

asin(1) = 1.571

arcsin(1) = 1.571

cos(π) = −1 // cosine

acos(−1) = 3.142

arccos(−1) = 3.142

tan(π / 4) = 1 // tangent

atan(1) = 0.785

arctan(1) = 0.785


## Text


Lines starting with an uppercase letter and containing at least 3 words separated by spaces or commas are considered paragraphs. The familiar Markdown-like formatting is supported inside text:


*italic* or _italic_

**bold** or __bold__

***bold italic*** or ___bold italic___

**_bold italic_ inside bold**

\*escaping\*

`preformatted: *regular*`


As an extension, you can also embed expressions into text using braces: {1 + 1}.


### Lists


Numbered list items begin with an integer number, followed by a dot and then by a space. Use `?. ` to automatically assign a number to an item. The second item is automatically numbered in the following list:


1. first item

2. second item


Bulleted list items begin with `-`, `*`, `+` or `?` followed by a space:


bullet

+ pros

- cons

? investigate


## Comments


Line comments start with `//`, any following text until the end of the line is considered a comment:


// calculate 2

1 + 1 = 2 // should be 2


Comments support Markdown-like formatting. If you want to disable the formatting, just omit the space after `//`:


// this comment is **formatted**

//this comment is **not** formatted