Skip to main content

Int

Integers default to 64 bit signed numbers.

let x = 42

Other integer sizes supported are described below. To declare a variable with a specific integer size, append the size suffix to the value.

F# EquivalentDescriptionSuffixExamples
int8signed 8 bit numberylet fizz = 42y
uint8unsigned 8 bit numberuylet buzz = 42uy
int16signed 16 bit numberslet fizz = 42s
uint16unsigned 16 bit numberuslet buzz = 42us
int32signed 32 bit numberllet fizz = 42l
uint32unsigned 32 bit numberullet buzz = 42ul
int64signed 64 bit number (default)Llet fizz = 42 (no suffix)
uint64unsigned 64 bit numberuLlet buzz = 42uL
int128signed 128 bit numberQlet fizz = 42Q
uint128unsigned 128 bit numberZlet buzz = 42Z

Functions

Absolute Value

The mathmatical absolute value of the integer.

Definition

Int.absoluteValue(Int: a) -> Int

Example

let x = -1
let y = 1
let X = Int.absoluteValue x
let Y = Int.absoluteValue y
[X,Y]

This trace returns: [1,1]


Add

The sum of two integers.

Definition

Int.add(Int: a, Int: b) -> Int

Example

let x = -1
let y = 1
let z = Int.add x y
z

This trace returns: 0


Clamp

Constrains a value to a range. If the value is within the range defined by the parameters the input value is returned. If the value is outside the range, the range boundary closest to the input value is returned.

Definition

Int.clamp(Int: value, Int: limitA, Int: limitB) -> Int

ParameterDefinition
valueThe input value to check against the range bounds.
limitAOne end of the range.
limitBThe other end of the range.

Examples

let value = 5
let lowerBound = 1
let upperBound = 9
Int.clamp value lowerBound upperBound

This trace returns: 5

let value = 10
let lowerBound = 1
let upperBound = 9
Int.clamp value upperBound lowerBound

This trace returns: 9