# Pascal-Chapter Math

### Chapter 4 : Math

Hello, I’m Dr Zod, I hope you didn’t sleep during your Math class in the academy because you’re gonna need it! Your ship needs at least 1.21 gigawatts to function properly. Battery packs are 0.16 gigawatts per unit. How many battery packs do you need? Seems easy, right? Well, no, because the system doesn’t run floating point numbers, so… good luck with that!

LIGO offers three built-in numerical types:

• int are integers, such as 10, -6 and 0.
• nat are natural numbers (integral numbers greater than or equal to zero). They are followed by the suffix n such as 3n, 12n and 0n for the natural zero.
• tez are units of measure of Tezos tokens. They can be decimals and are followed by tez or tz such as 3tz or 12.4tez. You can also type units of millionth of tez, using the suffix mutez after a natural literal, such as 10000mutez or 0mutez.

⚠️ Notice there are no floating point types in LIGO as they are not determinist in hardware modules.

ℹ️Large integral values can be expressed using underscores to separate groups of digits, like 1_000mutez or 0.000_004tez. Notice 1tez = 1_000_000mutez.

Addition in LIGO is accomplished by means of the + infix operator. Some type constraints apply, for example you cannot add a value of type tez to a value of type nat.

const a : int = 5 + 10
const b : int = 5n + 10
const c : tez = 5mutez + 0.000_010tez

⚠️ You cannot add a tez and a int.

#### Subtraction

const a : int = 5 – 10
const b : int = 5n – 2n
const d : tez = 5mutez – 1mutez

#### Multiplication

const a : int = 5 * 5
const b : nat = 5n * 5n
const c : tez = 5n * 5mutez

#### Division

const a : int = 10 / 3
const b : nat = 10n / 3n
const c : nat = 10mutez / 3mutez

⚠️ Remember that there are no floating point numbers in LIGO so dividing 9 by 2 will output 4 and not 4.5

#### Modulo

const a : int = 120
const b : int = 9
const rem1 : nat = a mod b // 3

⚠️ Remember that there are no floating point numbers in LIGO so dividing 9 by 2 will output 4 and not 4.5

#### Checking a nat

is_nat returns a nat or None

const is_a_nat : option (nat) = is_nat (1)