Int16
The convention is to name the module alias after the file name it is defined in:
import Int16 "mo:base/Int16";
On this page
Constants
Value minimumValue
Value maximumValue
Conversion
Function toInt
Function toText
Function fromInt
Function fromIntWrap
Function fromNat16
Function toNat16
Comparison
Function min
Function max
Function equal
Function notEqual
Function less
Function lessOrEqual
Function greater
Function greaterOrEqual
Function compare
Numerical Operations
Function abs
Function neg
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 : Int16 = -32_768;
maximumValue
let maximumValue : Int16 = 32_767;
Int16.toInt
func toInt(i : Int16) : Int
The function toInt
takes one Int16
value and returns an Int
value.
import Int16 "mo:base/Int16";
let a : Int16 = -32768;
Int16.toInt(a);
Int16.toText
func toText(i : Int16) : Text
The function toText
takes one Int16
value and returns a Text
value.
import Int16 "mo:base/Int16";
let b : Int16 = -32768;
Int16.toText(b);
Int16.fromInt
func fromInt(i : Int) : Int16
The function fromInt
takes one Int
value and returns an Int16
value.
import Int16 "mo:base/Int16";
let integer : Int = -32768;
Int16.fromInt(integer);
Int16.fromIntWrap
func fromIntWrap(i : Int) : Int16
The function fromIntWrap
takes one Int
value and returns an Int16
value.
import Int16 "mo:base/Int16";
let integer : Int = 65535;
Int16.fromIntWrap(integer);
Int16.fromNat16
func fromNat16(i : Nat16) : Int16
The function fromNat16
takes one Nat16
value and returns an Int16
value.
import Int16 "mo:base/Int16";
let nat16 : Nat16 = 65535;
Int16.fromNat16(nat16);
Int16.toNat16
func toNat16(i : Int16) : Nat16
The function toNat16
takes one Int16
value and returns an Nat16
value.
import Int16 "mo:base/Int16";
let int16 : Int16 = -32768;
Int16.toNat16(int16);
Int16.min
func min(x : Int16, y : Int16) : Int16
The function min
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 200;
let y : Int16 = 100;
Int16.min(x, y);
Int16.max
func max(x : Int16, y : Int16) : Int16
The function max
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 200;
let y : Int16 = 100;
Int16.max(x, y);
Int16.equal
func equal(x : Int16, y : Int16) : Bool
The function equal
takes two Int16
value and returns a Bool
value.
import Int16 "mo:base/Int16";
let x : Int16 = 10;
let y : Int16 = 10;
Int16.equal(x, y);
Int16.notEqual
func notEqual(x : Int16, y : Int16) : Bool
The function notEqual
takes two Int16
value and returns a Bool
value.
import Int16 "mo:base/Int16";
let x : Int16 = 100;
let y : Int16 = 100;
Int16.notEqual(x, y);
Int16.less
func less(x : Int16, y : Int16) : Bool
The function less
takes two Int16
value and returns a Bool
value.
import Int16 "mo:base/Int16";
let x : Int16 = 255;
let y : Int16 = 256;
Int16.less(x, y);
Int16.lessOrEqual
func lessOrEqual(x : Int16, y : Int16) : Bool
The function lessOrEqual
takes two Int16
value and returns a Bool
value.
import Int16 "mo:base/Int16";
let x : Int16 = 255;
let y : Int16 = 256;
Int16.lessOrEqual(x, y);
Int16.greater
func greater(x : Int16, y : Int16) : Bool
The function greater
takes two Int16
value and returns a Bool
value.
import Int16 "mo:base/Int16";
let x : Int16 = 150;
let y : Int16 = 100;
Int16.greater(x, y);
Int16.greaterOrEqual
func greaterOrEqual(x : Int16, y : Int16) : Bool
The function greaterOrEqual
takes two Int16
value and returns a Bool
value.
import Int16 "mo:base/Int16";
let x : Int16 = 150;
let y : Int16 = 100;
Int16.greaterOrEqual(x, y);
Int16.compare
func compare(x : Int16, y : Int16) : Bool
The function compare
takes two Int16
value and returns an Order variant value.
import Int16 "mo:base/Int16";
let x : Int16 = 1001;
let y : Int16 = 1000;
Int16.compare(x, y);
Int16.abs
func abs(x : Int16) : Int16
The function abs
takes one Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = -40;
Int16.abs(x);
Int16.neg
func neg(x : Int16) : Int16
The function neg
takes one Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = -50;
Int16.neg(x);
Int16.add
func add(x : Int16, y : Int16) : Int16
The function add
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 400;
let y : Int16 = 100;
Int16.add(x, y);
Int16.sub
func sub(x : Int16, y : Int16) : Int16
The function sub
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 400;
let y : Int16 = 200;
Int16.sub(x, y);
Int16.mul
func mul(x : Int16, y : Int16) : Int16
The function mul
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 20;
let y : Int16 = 50;
Int16.mul(x, y);
Int16.div
func div(x : Int16, y : Int16) : Int16
The function div
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 5000;
let y : Int16 = 50;
Int16.div(x, y);
Int16.rem
func rem(x : Int16, y : Int16) : Int16
The function rem
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 400;
let y : Int16 = 150;
Int16.rem(x, y);
Int16.pow
func pow(x : Int16, y : Int16) : Int16
The function pow
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 10;
let y : Int16 = 4;
Int16.pow(x, y);
Int16.bitnot
func bitnot(x : Int16) : Int16
The function bitnot
takes one Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 255; // Binary : 00000000_11111111
Int16.bitnot(x) // Binary : 11111111_00000000
Int16.bitand
func bitand(x : Int16, y : Int16) : Int16
The function bitand
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 255; // Binary : 00000000_11111111
let y : Int16 = 5; // Binary : 00000000_00000101
Int16.bitand(x, y)
Int16.bitor
func bitor(x : Int16, y : Int16) : Int16
The function bitor
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 240; // Binary : 00000000_11110000
let y : Int16 = 15; // Binary : 00000000_00001111
Int16.bitor(x, y) // Binary : 00000000_11111111
Int16.bitxor
func bitxor(x : Int16, y : Int16) : Int16
The function bitxor
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 255; // Binary : 00000000_11111111
let y : Int16 = 240; // Binary : 00000000_11110000
Int16.bitxor(x, y) // Binary : 00000000_00001111
Int16.bitshiftLeft
func bitshiftLeft(x : Int16, y : Int16) : Int16
The function bitshiftLeft
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 15; // Binary : 00000000_00001111
let y : Int16 = 4;
Int16.bitshiftLeft(x, y) // Binary : 00000000_11110000
Int16.bitshiftRight
func bitshiftRight(x : Int16, y : Int16) : Int16
The function bitshiftRight
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 240; // Binary : 00000000_11110000
let y : Int16 = 4;
Int16.bitshiftRight(x, y) // Binary : 00000000_00001111
Int16.bitrotLeft
func bitrotLeft(x : Int16, y : Int16) : Int16
The function bitrotLeft
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 32767; // Binary : 01111111_11111111
let y : Int16 = 1;
Int16.bitrotLeft(x, y) // Binary : 11111111_11111110
Int16.bitrotRight
func bitrotRight(x : Int16, y : Int16) : Int16
The function bitrotRight
takes two Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 32767; // Binary : 01111111_11111111
let y : Int16 = 1;
Int16.bitrotRight(x, y) // Binary : 10111111_11111111
Int16.bittest
func bittest(x : Int16, p : Nat) : Bool
The function bittest
takes one Int16
and one Nat
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 255; // Binary : 00000000_11111111
let p : Nat = 7;
Int16.bittest(x, p)
Int16.bitset
func bitset(x : Int16, p : Nat) : Bool
The function bitset
takes one Int16
and one Nat
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 127; // Binary : 00000000_01111111
let p : Nat = 7;
Int16.bitset(x, p) // Binary : 00000000_11111111
Int16.bitclear
func bitclear(x : Int16, p : Nat) : Bool
The function bitclear
takes one Int16
and one Nat
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 255; // Binary : 00000000_11111111
let p : Nat = 7;
Int16.bitclear(x, p) // Binary : 00000000_01111111
Int16.bitflip
func bitflip(x : Int16, p : Nat) : Bool
The function bitflip
takes one Int16
and one Nat
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 255; // Binary : 00000000_11111111
let p : Nat = 7;
Int16.bitflip(x, p) // Binary : 00000000_11011111
Int16.bitcountNonZero
let bitcountNonZero : (x : Int16) -> Int16
The function bitcountNonZero
takes one Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 255; // Binary : 00000000_11111111
Int16.bitcountNonZero(x)
Int16.bitcountLeadingZero
let bitcountLeadingZero : (x : Int16) -> Int16
The function bitcountLeadingZero
takes one Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 255; // Binary : 00000000_11111111
Int16.bitcountLeadingZero(x)
Int16.bitcountTrailingZero
let bitcountTrailingZero : (x : Int16) -> Int16
The function bitcountTrailingZero
takes one Int16
value and returns a Int16
value.
import Int16 "mo:base/Int16";
let x : Int16 = 128; // Binary : 00000000_10000000
Int16.bitcountTrailingZero(x)
Int16.addWrap
func addWrap(x : Int16, y : Int16) : Int16
The function addWrap
takes two Int16
value and returns a Int16
value.It is equivalent to the +%
Bitwise operators.
import Int16 "mo:base/Int16";
let x : Int16 = 32767;
let y : Int16 = 2;
Int16.addWrap(x, y)
Int16.subWrap
func subWrap(x : Int16, y : Int16) : Int16
The function subWrap
takes two Int16
value and returns a Int16
value.It is equivalent to the -%
Bitwise operators.
import Int16 "mo:base/Int16";
let x : Int16 = -32767;
let y : Int16 = 2;
Int16.subWrap(x, y)
Int16.mulWrap
func mulWrap(x : Int16, y : Int16) : Int16
The function mulWrap
takes two Int16
value and returns a Int16
value.It is equivalent to the *%
Bitwise operators.
import Int16 "mo:base/Int16";
let x : Int16 = 32767;
let y : Int16 = 2;
Int16.mulWrap(x, y)
Int16.powWrap
func powWrap(x : Int16, y : Int16) : Int16
The function powWrap
takes two Int16
value and returns a Int16
value.It is equivalent to the **%
Bitwise operators.
import Int16 "mo:base/Int16";
let x : Int16 = 255;
let y : Int16 = 2;
Int16.powWrap(x, y)