Nat64
The convention is to name the module alias after the file name it is defined in:
import Nat64 "mo:base/Nat64";
On this page
Constants
Value minimumValue
Value maximumValue
Conversion
Function toNat
Function toText
Function fromNat
Function fromIntWrap
Comparison
Function min
Function max
Function equal
Function notEqual
Function less
Function lessOrEqual
Function greater
Function greaterOrEqual
Function compare
Numerical Operations
Function add
Function sub
Function mul
Function div
Function rem
Function pow
Bitwise Operators
Function bitnot
Function bitand
Function bitor
Function bitxor
Function bitshiftLeft
Function bitshiftRight
Function bitrotLeft
Function bitrotRight
Function bittest
Function bitset
Function bitclear
Function bitflip
Function bitcountNonZero
Function bitcountLeadingZero
Function bitcountTrailingZero
Wrapping Operations
Function addWrap
Function subWrap
Function mulWrap
Function powWrap
minimumValue
let minimumValue : Nat64 = 0;
maximumValue
let maximumValue : Nat64 = 18_446_744_073_709_551_615;
Nat64.toNat
func toNat(i : Nat64) : Nat
The function toNat
takes one Nat64
value and returns an Nat
value.
import Nat64 "mo:base/Nat64";
let a : Nat64 = 184467;
Nat64.toNat(a);
Nat64.toText
func toText(i : Nat64) : Text
The function toText
takes one Nat64
value and returns a Text
value.
import Nat64 "mo:base/Nat64";
let b : Nat64 = 184467;
Nat64.toText(b);
Nat64.fromNat
func fromNat(i : Nat) : Nat64
The function fromNat
takes one Nat
value and returns an Nat64
value.
import Nat64 "mo:base/Nat64";
let number : Nat = 184467;
Nat64.fromNat(number);
Nat64.fromIntWrap
func fromIntWrap(i : Int) : Nat64
The function fromIntWrap
takes one Int
value and returns an Nat64
value.
import Nat64 "mo:base/Nat64";
let integer : Int = 18_446_744_073_709_551_616;
Nat64.fromIntWrap(integer);
Nat64.min
func min(x : Nat64, y : Nat64) : Nat64
The function min
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 2000;
let y : Nat64 = 1001;
Nat64.min(x, y);
Nat64.max
func max(x : Nat64, y : Nat64) : Nat64
The function max
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 2000;
let y : Nat64 = 2001;
Nat64.max(x, y);
Nat64.equal
func equal(x : Nat64, y : Nat64) : Bool
The function equal
takes two Nat64
value and returns a Bool
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 1000;
let y : Nat64 = 100;
Nat64.equal(x, y);
Nat64.notEqual
func notEqual(x : Nat64, y : Nat64) : Bool
The function notEqual
takes two Nat64
value and returns a Bool
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 1000;
let y : Nat64 = 1001;
Nat64.notEqual(x, y);
Nat64.less
func less(x : Nat64, y : Nat64) : Bool
The function less
takes two Nat64
value and returns a Bool
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 2000;
let y : Nat64 = 2500;
Nat64.less(x, y);
Nat64.lessOrEqual
func lessOrEqual(x : Nat64, y : Nat64) : Bool
The function lessOrEqual
takes two Nat64
value and returns a Bool
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 2000;
let y : Nat64 = 2500;
Nat64.lessOrEqual(x, y);
Nat64.greater
func greater(x : Nat64, y : Nat64) : Bool
The function greater
takes two Nat64
value and returns a Bool
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 2000;
let y : Nat64 = 1000;
Nat64.greater(x, y);
Nat64.greaterOrEqual
func greaterOrEqual(x : Nat64, y : Nat64) : Bool
The function greaterOrEqual
takes two Nat64
value and returns a Bool
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 2000;
let y : Nat64 = 1000;
Nat64.greaterOrEqual(x, y);
Nat64.compare
func compare(x : Nat64, y : Nat64) : Bool
The function compare
takes two Nat64
value and returns an Order variant value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 10000;
let y : Nat64 = 9999;
Nat64.compare(x, y);
Nat64.add
func add(x : Nat64, y : Nat64) : Nat64
The function add
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 2000;
let y : Nat64 = 1200;
Nat64.add(x, y);
Nat64.sub
func sub(x : Nat64, y : Nat64) : Nat64
The function sub
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 4000;
let y : Nat64 = 3999;
Nat64.sub(x, y);
Nat64.mul
func mul(x : Nat64, y : Nat64) : Nat64
The function mul
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 200;
let y : Nat64 = 50;
Nat64.mul(x, y);
Nat64.div
func div(x : Nat64, y : Nat64) : Nat64
The function div
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 5000;
let y : Nat64 = 500;
Nat64.div(x, y);
Nat64.rem
func rem(x : Nat64, y : Nat64) : Nat64
The function rem
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 4000;
let y : Nat64 = 1200;
Nat64.rem(x, y);
Nat64.pow
func pow(x : Nat64, y : Nat64) : Nat64
The function pow
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 10;
let y : Nat64 = 5;
Nat64.pow(x, y);
Nat64.bitnot
func bitnot(x : Nat64) : Nat64
The function bitnot
takes one Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 18_446_744_073_709_551_360;
Nat64.bitnot(x)
Nat64.bitand
func bitand(x : Nat64, y : Nat64) : Nat64
The function bitand
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 4294967295;
let y : Nat64 = 255;
Nat64.bitand(x, y)
Nat64.bitor
func bitor(x : Nat64, y : Nat64) : Nat64
The function bitor
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 240;
let y : Nat64 = 15;
Nat64.bitor(x, y)
Nat64.bitxor
func bitxor(x : Nat64, y : Nat64) : Nat64
The function bitxor
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 255;
let y : Nat64 = 240;
Nat64.bitxor(x, y)
Nat64.bitshiftLeft
func bitshiftLeft(x : Nat64, y : Nat64) : Nat64
The function bitshiftLeft
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 15;
let y : Nat64 = 4;
Nat64.bitshiftLeft(x, y)
Nat64.bitshiftRight
func bitshiftRight(x : Nat64, y : Nat64) : Nat64
The function bitshiftRight
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 240;
let y : Nat64 = 4;
Nat64.bitshiftRight(x, y)
Nat64.bitrotLeft
func bitrotLeft(x : Nat64, y : Nat64) : Nat64
The function bitrotLeft
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 4_278_190_080;
let y : Nat64 = 8;
Nat64.bitrotLeft(x, y)
Nat64.bitrotRight
func bitrotRight(x : Nat64, y : Nat64) : Nat64
The function bitrotRight
takes two Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 255;
let y : Nat64 = 8;
Nat64.bitrotRight(x, y)
Nat64.bittest
func bittest(x : Nat64, p : Nat) : Bool
The function bittest
takes one Nat64
and one Nat
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 255;
let p : Nat = 7;
Nat64.bittest(x, p)
Nat64.bitset
func bitset(x : Nat64, p : Nat) : Bool
The function bitset
takes one Nat64
and one Nat
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 127;
let p : Nat = 7;
Nat64.bitset(x, p)
Nat64.bitclear
func bitclear(x : Nat64, p : Nat) : Bool
The function bitclear
takes one Nat64
and one Nat
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 255;
let p : Nat = 7;
Nat64.bitclear(x, p)
Nat64.bitflip
func bitflip(x : Nat64, p : Nat) : Bool
The function bitflip
takes one Nat64
and one Nat
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 255;
let p : Nat = 7;
Nat64.bitflip(x, p)
Nat64.bitcountNonZero
let bitcountNonZero : (x : Nat64) -> Nat64
The function bitcountNonZero
takes one Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 255;
Nat64.bitcountNonZero(x)
Nat64.bitcountLeadingZero
let bitcountLeadingZero : (x : Nat64) -> Nat64
The function bitcountLeadingZero
takes one Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 255;
Nat64.bitcountLeadingZero(x)
Nat64.bitcountTrailingZero
let bitcountTrailingZero : (x : Nat64) -> Nat64
The function bitcountTrailingZero
takes one Nat64
value and returns a Nat64
value.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 128;
Nat64.bitcountTrailingZero(x)
Nat64.addWrap
func addWrap(x : Nat64, y : Nat64) : Nat64
The function addWrap
takes two Nat64
value and returns a Nat64
value.It is equivalent to the +%
Bitwise operators.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 18_446_744_073_709_551_615;
let y : Nat64 = 1;
Nat64.addWrap(x, y)
Nat64.subWrap
func subWrap(x : Nat64, y : Nat64) : Nat64
The function subWrap
takes two Nat64
value and returns a Nat64
value.It is equivalent to the -%
Bitwise operators.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 0;
let y : Nat64 = 2;
Nat64.subWrap(x, y)
Nat64.mulWrap
func mulWrap(x : Nat64, y : Nat64) : Nat64
The function mulWrap
takes two Nat64
value and returns a Nat64
value.It is equivalent to the *%
Bitwise operators.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 4294967296;
let y : Nat64 = 4294967296;
Nat64.mulWrap(x, y)
Nat64.powWrap
func powWrap(x : Nat64, y : Nat64) : Nat64
The function powWrap
takes two Nat64
value and returns a Nat64
value.It is equivalent to the **%
Bitwise operators.
import Nat64 "mo:base/Nat64";
let x : Nat64 = 4294967296;
let y : Nat64 = 2;
Nat64.powWrap(x, y)