Tcalc expressions are pretty similar to ordinary programming languages, here are some examples:
if
statement is also supported:
Users can also terminate an expression with a semicolon:
Operator | Description | Priority |
---|---|---|
* | Multiplication | 3 |
/ | Division | 3 |
+ | Addition | 2 |
- | Subtraction | 2 |
== | Equal to | 1 |
!= | Not equal to | 1 |
> | Greater than | 1 |
< | Less than | 1 |
>= | Greater than or equal to | 1 |
<= | Less than or equal to | 1 |
&& | Logical AND | 0 |
\|\| | Logical OR | 0 |
Operator | Description |
---|---|
- | Negate |
+ | Identity |
! | Logical NOT |
Tcalc use alphanumeric characters, underscores and Decimal digits to form identifiers. Identifiers must start with a letter or an underscore, here are some examples:
If you want to use a non-standard identifier, you can use signle quotes:
Use def
keyword to define a function:
Tcalc also supports recursive functions:
You can call a function by its name with arguments:
Function | Description |
---|---|
sqrt(x) | Square root |
pow(x, y) | Power |
sin(x) | Sine |
cos(x) | Cosine |
tan(x) | Tangent |
asin(x) | Arcsine |
acos(x) | Arccosine |
atan(x) | Arctangent |
Use let
keyword to assign a value to a variable:
You can also assign a value to a variable in an expression:
Variable | Description |
---|---|
pi | Pi |
e | Euler's number |
Use import
keyword to import a module:
or: