ESC
No recent searches
Search by
Standard Library  /  Int64

Int64

Utilities for working with the Int64 type.

Edit on GitHub
Added in 0.2.0 No other changes yet.
from "int64" include Int64
1L
-1L

Values

Functions and constants included in the Int64 module.

Int64.fromNumber

Added in 0.2.0 No other changes yet.
fromNumber : (number: Number) => Int64

Converts a Number to an Int64.

Parameters:

number: The value to convert

Returns:

Int64: The Number represented as an Int64

Int64.toNumber

Added in 0.2.0 No other changes yet.
toNumber : (value: Int64) => Number

Converts an Int64 to a Number.

Parameters:

value: The value to convert

Returns:

Number: The Int64 represented as a Number

Int64.fromUint64

Added in 0.6.0 No other changes yet.
fromUint64 : (number: Uint64) => Int64

Converts a Uint64 to an Int64.

Parameters:

number: The value to convert

Returns:

Int64: The Uint64 represented as an Int64

Examples:

Int64.fromUint64(1uL) == 1L

Int64.incr

Added in 0.2.0 No other changes yet.
incr : (value: Int64) => Int64

Increments the value by one.

Parameters:

value: The value to increment

Returns:

Int64: The incremented value

Examples:

Int64.incr(1L) == 2L
Int64.incr(-2L) == -1L

Int64.decr

Added in 0.2.0 No other changes yet.
decr : (value: Int64) => Int64

Decrements the value by one.

Parameters:

value: The value to decrement

Returns:

Int64: The decremented value

Examples:

Int64.decr(2L) == 1L
Int64.decr(0L) == -1L

Int64.(+)

Added in 0.6.0
versionchanges
0.2.0Originally named `add`
(+) : (x: Int64, y: Int64) => Int64

Computes the sum of its operands.

Parameters:

x: The first operand
y: The second operand

Returns:

Int64: The sum of the two operands

Examples:

use Int64.{ (+) }
assert 1L + 1L == 2L

Int64.(-)

Added in 0.6.0
versionchanges
0.2.0Originally named `sub`
(-) : (x: Int64, y: Int64) => Int64

Computes the difference of its operands.

Parameters:

x: The first operand
y: The second operand

Returns:

Int64: The difference of the two operands

Examples:

use Int64.{ (-) }
assert 2L - 1L == 1L

Int64.(*)

Added in 0.6.0
versionchanges
0.2.0Originally named `*`
(*) : (x: Int64, y: Int64) => Int64

Computes the product of its operands.

Parameters:

x: The first operand
y: The second operand

Returns:

Int64: The product of the two operands

Examples:

use Int64.{ (*) }
assert 2L * 2L == 4L

Int64.(/)

Added in 0.6.0
versionchanges
0.2.0Originally named `div`
(/) : (x: Int64, y: Int64) => Int64

Computes the quotient of its operands using signed division.

Parameters:

x: The first operand
y: The second operand

Returns:

Int64: The quotient of its operands

Examples:

use Int64.{ (/) }
assert 8L / 2L == 4L

Int64.rem

Added in 0.2.0 No other changes yet.
rem : (x: Int64, y: Int64) => Int64

Computes the remainder of the division of its operands using signed division.

Parameters:

x: The first operand
y: The second operand

Returns:

Int64: The remainder of its operands

Examples:

Int64.rem(8L, 3L) == 2L

Int64.(%)

Added in 0.6.0
versionchanges
0.2.0Originally named `mod`
(%) : (x: Int64, y: Int64) => Int64

Computes the remainder of the division of the first operand by the second. The result will have the sign of the second operand.

Parameters:

x: The first operand
y: The second operand

Returns:

Int64: The modulus of its operands

Throws:

ModuloByZero

  • When y is zero

Examples:

use Int64.{ (%) }
assert -5L % 3L == 1L

Int64.rotl

Added in 0.4.0 No other changes yet.
rotl : (value: Int64, amount: Int64) => Int64

Rotates the bits of the value left by the given number of bits.

Parameters:

value: The value to rotate
amount: The number of bits to rotate by

Returns:

Int64: The rotated value

Examples:

Int64.rotl(1L, 1L) == 2L
Int64.rotl(1L, 2L) == 4L

Int64.rotr

Added in 0.4.0 No other changes yet.
rotr : (value: Int64, amount: Int64) => Int64

Rotates the bits of the value right by the given number of bits.

Parameters:

value: The value to rotate
amount: The number of bits to rotate by

Returns:

Int64: The rotated value

Examples:

Int64.rotr(2L, 1L) == 1L
Int64.rotr(4L, 2L) == 1L

Int64.(<<)

Added in 0.6.0
versionchanges
0.2.0Originally named `shl`
(<<) : (value: Int64, amount: Int64) => Int64

Shifts the bits of the value left by the given number of bits.

Parameters:

value: The value to shift
amount: The number of bits to shift by

Returns:

Int64: The shifted value

Examples:

use Int64.{ (<<) }
assert (5L << 1L) == 10L

Int64.(>>)

Added in 0.6.0
versionchanges
0.2.0Originally named `shr`
(>>) : (value: Int64, amount: Int64) => Int64

Shifts the bits of the value right by the given number of bits, preserving the sign bit.

Parameters:

value: The value to shift
amount: The amount to shift by

Returns:

Int64: The shifted value

Examples:

use Int64.{ (>>) }
assert (5L >> 1L) == 2L

Int64.(==)

Added in 0.6.0
versionchanges
0.4.0Originally named `eq`
(==) : (x: Int64, y: Int64) => Bool

Checks if the first value is equal to the second value.

Parameters:

x: The first value
y: The second value

Returns:

Bool: true if the first value is equal to the second value or false otherwise

Examples:

use Int64.{ (==) }
assert 1L == 1L

Int64.(!=)

Added in 0.6.0
versionchanges
0.4.0Originally named `ne`
(!=) : (x: Int64, y: Int64) => Bool

Checks if the first value is not equal to the second value.

Parameters:

x: The first value
y: The second value

Returns:

Bool: true if the first value is not equal to the second value or false otherwise

Examples:

use Int64.{ (!=) }
assert 1L != 2L

Int64.eqz

Added in 0.4.0 No other changes yet.
eqz : (value: Int64) => Bool

Checks if the given value is equal to zero.

Parameters:

value: The value to inspect

Returns:

Bool: true if the first value is equal to zero or false otherwise

Examples:

Int64.eqz(0L) == true
Int64.eqz(1L) == false

Int64.(<)

Added in 0.6.0
versionchanges
0.2.0Originally named `lt`
(<) : (x: Int64, y: Int64) => Bool

Checks if the first value is less than the second value.

Parameters:

x: The first value
y: The second value

Returns:

Bool: true if the first value is less than the second value or false otherwise

Examples:

use Int64.{ (<) }
assert 1L < 2L

Int64.(>)

Added in 0.6.0
versionchanges
0.2.0Originally named `gt`
(>) : (x: Int64, y: Int64) => Bool

Checks if the first value is greater than the second value.

Parameters:

x: The first value
y: The second value

Returns:

Bool: true if the first value is greater than the second value or false otherwise

Examples:

use Int64.{ (>) }
assert 2L > 1L

Int64.(<=)

Added in 0.6.0
versionchanges
0.2.0Originally named `lte`
(<=) : (x: Int64, y: Int64) => Bool

Checks if the first value is less than or equal to the second value.

Parameters:

x: The first value
y: The second value

Returns:

Bool: true if the first value is less than or equal to the second value or false otherwise

Examples:

use Int64.{ (<=) }
assert 1L <= 2L
use Int64.{ (<=) }
assert 1L <= 1L

Int64.(>=)

Added in 0.6.0
versionchanges
0.2.0Originally named `gte`
(>=) : (x: Int64, y: Int64) => Bool

Checks if the first value is greater than or equal to the second value.

Parameters:

x: The first value
y: The second value

Returns:

Bool: true if the first value is greater than or equal to the second value or false otherwise

Examples:

use Int64.{ (>=) }
assert 2L >= 1L
use Int64.{ (>=) }
assert 1L >= 1L

Int64.lnot

Added in 0.2.0 No other changes yet.
lnot : (value: Int64) => Int64

Computes the bitwise NOT of the given value.

Parameters:

value: The given value

Returns:

Int64: Containing the inverted bits of the given value

Examples:

Int64.lnot(-5L) == 4L

Int64.(&)

Added in 0.6.0
versionchanges
0.2.0Originally named `land`
(&) : (x: Int64, y: Int64) => Int64

Computes the bitwise AND (&) on the given operands.

Parameters:

x: The first operand
y: The second operand

Returns:

Int64: Containing a 1 in each bit position for which the corresponding bits of both operands are 1

Examples:

use Int64.{ (&) }
assert (3L & 4L) == 0L

Int64.(|)

Added in 0.6.0
versionchanges
0.2.0Originally named `lor`
(|) : (x: Int64, y: Int64) => Int64

Computes the bitwise OR (|) on the given operands.

Parameters:

x: The first operand
y: The second operand

Returns:

Int64: Containing a 1 in each bit position for which the corresponding bits of either or both operands are 1

Examples:

use Int64.{ (|) }
assert (3L | 4L) == 7L

Int64.(^)

Added in 0.6.0
versionchanges
0.2.0Originally named `lxor`
(^) : (x: Int64, y: Int64) => Int64

Computes the bitwise XOR (^) on the given operands.

Parameters:

x: The first operand
y: The second operand

Returns:

Int64: Containing a 1 in each bit position for which the corresponding bits of either but not both operands are 1

Examples:

use Int64.{ (^) }
assert (3L ^ 5L) == 6L

Int64.clz

Added in 0.4.0 No other changes yet.
clz : (value: Int64) => Int64

Counts the number of leading zero bits in the value.

Parameters:

value: The value to inspect

Returns:

Int64: The amount of leading zeros

Examples:

Int64.clz(1L) == 63L
Int64.clz(4L) == 61L

Int64.ctz

Added in 0.4.0 No other changes yet.
ctz : (value: Int64) => Int64

Counts the number of trailing zero bits in the value.

Parameters:

value: The value to inspect

Returns:

Int64: The amount of trailing zeros

Examples:

Int64.ctz(1L) == 0L
Int64.ctz(4L) == 2L

Int64.popcnt

Added in 0.4.0 No other changes yet.
popcnt : (value: Int64) => Int64

Counts the number of bits set to 1 in the value, also known as a population count.

Parameters:

value: The value to inspect

Returns:

Int64: The amount of 1-bits in its operand

Examples:

Int64.popcnt(1L) == 1L
Int64.popcnt(3L) == 2L

Int64.(**)

Added in 0.6.0 No other changes yet.
(**) : (base: Int64, power: Int64) => Int64

Computes the exponentiation of the given base and power.

Parameters:

base: The base number
power: The exponent number

Returns:

Int64: The base raised to the given power

Examples:

from Int64 use { (**) }
assert 2L ** 3L == 8L

Sign up for farm-to-inbox developer news

You can unsubscribe at any time. Read our privacy policy.

Copyright © 2024 The Grain Programming Language