Boris Math Parser and Evaluator

Boris is capable of reading and evaluating mathematics formulas according to the following given rules.

First of all, a quick example :

= cos(2.3) + 7

CAUTION : Do not forget the leading "=" character !
You'll get the following answer from Boris :

= 7.999194 (DEG)

Angle Unit

Note that Boris allows you to modify the default used angle unit (degree, radian, gradian) for your trigonometry calculus by using the !angle command.

Input Format

Boris supports 3 kind of input formats :

  • Decimal (the default one)
    = 10.5
    
  • Hexadecimal
    = 0xF4E
    
    or :
    = F4Eh
    
  • Binary
    = 1011b
    

Output Format

By default, every result will be returned in DECIMAL format but you may also want to get your results in BINARY or HEXADECIMAL format.

Example :

= cos(2.3) + 7

By default, you'll get the following answer from Boris in DECIMAL mode :

= 7.999194 (DEG)

And to get your last result in BINARY format, just type :

= bin

Then, every following results will be BINARY formated.
To come back to DECIMAL, just type :

= dec

Or to get HEXADECIMAL :

= hex

Constants

Constant Name Description
pi PI (3.141592653589793238462643)
e Eulerian number (2.718281828459045235360287)
epsilon Epsilon (here, 1e-7)

Operators

Ope. Priority Description
< 2 less than
> 2 greater than
<= 2 less or equal
>= 2 greater or equal
!= 2 not equal
== 2 equal
+ 3 addition
- 3 subtraction
* 4 multiplication
/ 4 division
% 4 modulus
! 4 not (infix operator)

Binary Operators

Ope. Priority Description
"and" or "&" 1 logical AND
"or" or "|" 1 logical OR
"xor" or "^" 1 logical XOR
&& 1 AND
| | 1 OR
<< 5 shift left
>> 5 shift right

Postfix Operators

Ope. Priority Description
k 4 kilo (10001)
m 4 mega (10002)
g 4 giga (10003)
t 4 tera (10004)
p 4 peta (10005)
K 4 kilobyte (10241)
M 4 megabyte (10242)
G 4 gigabyte (10243)
T 4 terabyte (10244)
P 4 petabyte (10245)

Example :

= 2k

Will give you the following answer from Boris :

= 2000 (DEG)

But :

= 2K

Will give you :

= 2048 (DEG)

Functions

Name Args Count Description
abs 1 absolute value
ans 0 return the last result from Boris
exp 1 exponential
mod 1 modulus
pow 2 x raised to the power of y
pow2 1 val2
pow3 1 val3
sqr 1 see "pow2"
cube 1 see "pow3"
sqrt 1 square root of a value
sign 1 sign function -1 if x<0; 1 if x>0
round 1 round to nearest integer
trunc 1 truncate to get the integer part only

Functions : Conversion

Name Args Count Description
deg 1 convert a value from current angle unit to "degree"
rad 1 convert a value from current angle unit to "radian"
grad 1 convert a value from current angle unit to "gradian"
tok 1 "to kilo", value * 10001
tom 1 "to mega", value * 10002
tog 1 "to giga", value * 10003
tot 1 "to tera", value * 10004
top 1 "to peta", value * 10005
tokb 1 "to kilobytes", value * 10241
tomb 1 "to megabytes", value * 10242
togb 1 "to gigabytes", value * 10243
totb 1 "to terabytes", value * 10244
topb 1 "to petabytes", value * 10245

Functions : Random

Name Args Count Description
randunit 0 generate a random value in [0, 1]
rand 0 see "randunit"
randsym 0 symmetric random, generate a random value in [-1, 1]
randrange 2 generate a random value in [min, max]

Functions : Trigonometric, Arcus, Hyperbolic

Name Args Count Description
sin 1 sine function
cos 1 cosine function
tan 1 tangens function
acos 1 arcus cosine function
asin 1 arcus sine function
atan 1 arcus tangens function
cosh 1 hyperbolic cosine
sinh 1 hyperbolic sine function
tanh 1 hyperbolic tangens function
acosh 1 hyperbolic arcus tangens function
asinh 1 hyperbolic arcus sine function
atanh 1 hyperbolic arcur tangens function

Functions : Logarithm

Name Args Count Description
log2 1 logarithm to the base 2
log10 1 logarithm to the base 10
log 1 logarithm to the base 10
ln 1 logarithm to base e (2.71828...)

Functions : Variable Parameters

Name Args Count Description
avg variable mean value of all arguments
if 3 if ... then ... else ...
max variable max of all arguments
min variable min of all arguments
sum variable sum of all arguments