# Built in Operators¶

**Table of contents**- Built in Operators

There are three basic sets of operators available:

## Arithmetic¶

All of the arithmetic operators are included and available: `+`

, `-`

, `*`

, `/`

and of course `%`

(modulo).

## Boolean¶

Boolean operators will consider `false`

every value equal to zero (`0 ± 0.000000000001`

), and `true`

every other value.

But they are warrantied to return `1.0`

for `true`

and `0.0`

for `false`

. The available operators are: `&`

(and), `|`

(or), `¬`

(not).

There are also a set of Extra Functions and Operators

## Precedence¶

For those who don't know, precedence of operators refers to which of theoperators will be evaluated first when left alone. I won't bother you with numbers, the order of evaluation is as follows:

FIRST-> * / % - + ¬ & | == != <-LAST ----- --- - - - ----- ^^^ The dashes indicate groups with the same precedence

When operators have the same precedence they will be evaluated from left to right.

** Note:** as in primary school (and beyond) you can always alter the precedence of operators with the use of parentheses.

## Factorial¶

Factorial isn't technically an operator... it's a function but since it's so common, it's implemented by using the `!`

symbol and with more precedence than the arithmetic multiplication. Even though the implementation of operators is trivial in `exp4j`

the factorial is the only postfix unary operator, so it deserves a special case.

**Note:** Factorials from `0!`

to `21!`

are guaranteed to be correct, bigger than `21!`

may suffer lost of precision because of `double`

rounding.

**Note 2:** Factorials bigger than `170!`

will rise an `IllegalArgumentException`

since the value will be `Double.INFINITY`

.

## Code¶

The code for the operators is here.

Updated by Federico Vera about 1 year ago · 6 revisions

Go to top