Int
The convention is to name the module alias after the file name it is defined in:
import Int "mo:base/Int";
Numerical operations
Function abs
Function neg
Function add
Function sub
Function mul
Function div
Function rem
Function pow
Conversion
Comparison
Function min
Function max
Function equal
Function notEqual
Function less
Function lessOrEqual
Function greater
Function greaterOrEqual
Function compare
Int.abs
func abs(x : Int) : Nat
The function abs
takes one Int
value as a argument and returns a Nat
value.
import Int "mo:base/Int";
let integer : Int = -10;
Int.abs(integer);
Int.neg
func neg(x : Int) : Int
The function neg
takes one Int
value as a argument and returns an Int
value.
import Int "mo:base/Int";
let integer : Int = -10;
Int.neg(integer);
Int.add
func add(x : Int, y : Int) : Int
The function add
takes two Int
value as a argument and returns an Int
value.
import Int "mo:base/Int";
let a : Int = 30;
let b : Int = 20;
Int.add(a, b);
Int.sub
func sub(x : Int, y : Int) : Int
The function sub
takes two Int
value as a argument and returns an Int
value.
import Int "mo:base/Int";
let a : Int = 30;
let b : Int = 20;
Int.sub(a, b);
Int.mul
func mul(x : Int, y : Int) : Int
The function mul
takes two Int
value as a argument and returns an Int
value.
import Int "mo:base/Int";
let a : Int = 3;
let b : Int = 5;
Int.mul(a, b);
Int.div
func div(x : Int, y : Int) : Int
The function div
takes two Int
value as a argument and returns an Int
value.
import Int "mo:base/Int";
let a : Int = 30;
let b : Int = 10;
Int.div(a, b);
Int.rem
func rem(x : Int, y : Int) : Int
The function rem
takes two Int
value as a argument and returns an Int
value.
import Int "mo:base/Int";
let a : Int = 30;
let b : Int = 20;
Int.rem(a, b);
Int.pow
func pow(x : Int, y : Int) : Int
The function pow
takes two Int
as a argument and returns an Int
value.
import Int "mo:base/Int";
let a : Int = 3;
let b : Int = -3;
Int.pow(a, b);
Int.toText
func toText(x : Int) : Text
The function toText
takes one Int
value as a argument and returns a Text
value.
import Int "mo:base/Int";
let integer : Int = -10;
Int.toText(integer);
Int.min
func min(x : Int, y : Int) : Int
The function min
takes two Int
value as a arguments and returns an Int
value.
import Int "mo:base/Int";
let a : Int = 20;
let b : Int = -20;
Int.min(a, b);
Int.max
func max(x : Int, y : Int) : Int
The function max
takes two Int
value as a arguments and returns an Int
value.
import Int "mo:base/Int";
let a : Int = 20;
let b : Int = -20;
Int.max(a, b);
Int.equal
func equal(x : Int, y : Int) : Bool
The function equal
takes two Int
value as a arguments and returns an Bool
value.
import Int "mo:base/Int";
let a : Int = 20;
let b : Int = -20;
Int.equal(a, b);
Int.notEqual
func notEqual(x : Int, y : Int) : Bool
The function notEqual
takes two Int
value as a arguments and returns an Bool
value.
import Int "mo:base/Int";
let a : Int = 20;
let b : Int = -20;
Int.notEqual(a, b);
Int.less
func less(x : Int, y : Int) : Bool
The function less
takes two Int
value as a arguments and returns an Bool
value.
import Int "mo:base/Int";
let a : Int = 20;
let b : Int = -20;
Int.less(a, b);
Int.lessOrEqual
func lessOrEqual(x : Int, y : Int) : Bool
The function lessOrEqual
takes two Int
value as a arguments and returns an Bool
value.
import Int "mo:base/Int";
let a : Int = 20;
let b : Int = -20;
Int.lessOrEqual(a, b);
Int.greater
func greater(x : Int, y : Int) : Bool
The function greater
takes two Int
value as a arguments and returns an Bool
value.
import Int "mo:base/Int";
let a : Int = 20;
let b : Int = -20;
Int.greater(a, b);
Int.greaterOrEqual
func greaterOrEqual(x : Int, y : Int) : Bool
The function greaterOrEqual
takes two Int
value as a arguments and returns an Bool
value.
import Int "mo:base/Int";
let a : Int = 20;
let b : Int = -20;
Int.greaterOrEqual(a, b);
Int.compare
func compare(x : Int, y : Int) : {#less; #equal; #greater}
The function compare
takes two Int
value as a arguments and returns an Order variant value.
import Int "mo:base/Int";
let a : Int = 20;
let b : Int = -20;
Int.compare(a, b);