This manual page describe operators in Sncode

**Operators **- This manual page describe operators in Sncode

Here are the list of arithmetics operators.

Arithmetic operators are used to perform calculation on numbers:

56 * 65;

1 + 2 * 3 ** 4 / 5 * 6 - -1;

In mathematics and computer programming, the order of operations (sometimes called operator precedence) is a rule used to clarify which procedures should be performed first in a given mathematical expression.

For example, in mathematics and most computer languages, multiplication is done before addition; in the expression 2 + 3 × 4, the answer is 14.

To change the order of operators, grouping with () can be used as is (2+3) * 4, the answer is 20.

Sncode will change the type of the arguement to accomodate the operation.

A character will be transform into a number of 0 if its not possible. So 2 + "3.5" will yield 5.5. The string 3.5 is transform in the number 3.5.

Also note that the string "3.5abc" is 3.5 while "abc3.5dev" is 0.0.

Boolean true will be change to 1 while false while be change to 0.

Assignment is use to assign a value to a variable as in:

a = 5;

The expression of the right side on the assigment can be very simple as in '5' or can ve more complex as in : ' sigmoid = 1.0 / ( 1.0 + 2.71818 ** -5);'.

- is used to substract 2 number as in 5 - 3 remove 3 from 5 for an

+ is use to add 2 numbers as in 1 + 2;

As unary operations have only one operand they are evaluated before other operations containing them in common mathematics. Here is an example using negation:

- 3 − −2

* to multiply 2 numbers

/ to divide a number by another one.

In computing, the modulo operation finds the remainder after division of one number by another (sometimes called modulus).

Given two positive numbers, a (the dividend) and n (the divisor), a modulo n (abbreviated as a mod n) is the remainder of the Euclidean division of a by n. For instance, the expression "5 mod 2" would evaluate to 1 because 5 divided by 2 leaves a quotient of 2 and a remainder of 1, while "9 mod 3" would evaluate to 0 because the division of 9 by 3 has a quotient of 3 and leaves a remainder of 0; there is nothing to subtract from 9 after multiplying 3 times 3. (Note that doing the division with a calculator will not show the result referred to here by this operation; the quotient will be expressed as a decimal fraction.)

Exponentiation is a mathematical operation, written as ** b^{n}**, involving two numbers, the

The **order of operations** (sometimes called **operator precedence**) is a rule used to clarify which procedures should be performed first in a given mathematical expression.

For example, in mathematics and most computer languages, multiplication is done before addition; in the expression 2 + 3 × 4, the answer is 14. Brackets, "( and ), { and }, or [ and ]", which have their own rules, may be used to avoid confusion, thus the preceding expression may also be rendered 2 + (3 × 4), but the brackets are unnecessary as multiplication still has precedence without them.

The order of operations used throughout mathematics, science, technology and many computer programming languages is expressed here:[2]

exponents and modulo

multiplication and division

addition and subtraction

In sncode, when you perform an opeation on two variables of different type, Sncode will always try to keep the most significant digit to the result.

So if we have a=2; b=2.1; c=a+b; c.type() will be float and c; will be 4.1.

Sncode will have try to cast the value of a variable.

So if we have a=2; b="2.1"; c=a+b; c.type() will be float and c; will be 4.1.

- What is the answer of : 1 + 2 * 3
- What is the result of 5%2
- What is the answer of 1/2?

{{ include("includes/tutorial.sn") }}

Written by Pierre Laplante, <laplante@sednove.com>

1.0 2015-05-19 22:50:14 laplante@sednove.com

Edit© 2022 extenso Inc. All rights reserved.