BayES BayES

2.2 Arithmetic operations

In its simplest form BayES can be used as a desk calculator, which has the ability of storing values to user-defined variables. In this context, BayES supports:

  1. the basic arithmetic operations (addition, subtraction, multiplication, division)

  2. unary minus

  3. exponentiation

  4. functions for taking logarithms, square roots, etc.

  5. parentheses to group expressions

An example of using BayES as a calculator is given in Example 2.1. This example also illustrates that any line starting with a double slash is treated by BayES as a comment. Multi-line comments are enclosed in matching “/*" and “*/", as shown in Example 2.4.

Example 2.1
▼ Input ▼ Output
 
// Define an item with id value A and 
// print it on screen 
A = 3; 
print(A); 
 
// Define an item with id value B and 
// print it on screen 
B = 2*A - 4; 
print(B); 
 
// Define an item with id value C and 
// print it on screen 
C = 2*(A+3)^2 - 5/2*log(B); 
print(C);

 
A = 
  3 
 
 
B = 
  2 
 
 
C = 
  70.2671 
 
 
 

The term “id value" is used in this guide to denote the name of an item held in memory. In the example above three values were defined with names A, B and C. These names (id values) are then used to refer to the numerical values stored in the respective items.

Share this content:
Facebook Twitter LinkedIn Email
© 2016–20 Grigorios Emvalomatis