mav
LIGO offers some Mavryk-specific data types. Here we list some of them. Others have their own dedicated section.
The token unit on Mavryk is called mav
in LIGO. There are several
ways to write literal values of type mav
:
- units of millionth of
mav
, using the suffixmumav
after a natural number, like10000mumav
or0mumav
; - units of
mav
, using the suffixtz
ormav
, like3mv
or3mav
; - decimal amounts of
tz
ormav
, like12.3mv
or12.4mav
.
The type is
mav
, notmumav
--- which is a suffix to write literals.
Note that large amounts, like with numerical values of type int
and
nat
, can be expressed using underscores to separate groups of
digits, like 1_000mumav
(one thousand mumav) or 0.000_004mav
.
Adding
Addition in LIGO is accomplished by means of the +
infix
operator. Some type constraints apply, for example you cannot add a
value of type mav
to a value of type nat
.
In the following example you can find a series of arithmetic
operations, including various numerical types. However, some bits
remain in comments as they would otherwise not compile, for example,
adding a value of type int
to a value of type mav
is invalid. Note
that adding an integer to a natural number produces an integer.
Subtracting
Since subtracting two amounts could result in a negative amount,
subtraction of two mav
amounts result in an
optional amount, like so:
Multiplying
You can multiply nat
and mav
values:
Dividing
The division of two mav
values results into a nat
.
Euclidean Division
For cases when you need both the quotient and the remainder, LIGO
provides the ediv
operation. ediv(x,y)
returns Some (quotient,
remainder)
, unless y
is zero, in which case it returns None
. The
function ediv
is overloaded to accept mav, beyond all the
combinations of natural and integer numbers: