///|
test "basic operations" {
let i : Int64 = -12345L // Int64 literal
// You can also convert from an `Int` like so:
inspect(Int64::from_int(-12345) == i, content="true")
// Max and min values
inspect(@int64.MAX_VALUE, content="9223372036854775807")
inspect(@int64.MIN_VALUE, content="-9223372036854775808")
// Absolute value
inspect(Int64::abs(i), content="12345")
}///|
test "binary conversion" {
let x = 258L // Int64 value of 258
let be_bytes = x.to_be_bytes_local()
let le_bytes = x.to_le_bytes_local()
// Convert to String for inspection
inspect(
be_bytes.to_string(),
content=(
#|b"\x00\x00\x00\x00\x00\x00\x01\x02"
),
)
inspect(
le_bytes.to_string(),
content=(
#|b"\x02\x01\x00\x00\x00\x00\x00\x00"
),
)
// We can verify they represent the same number but in different byte orders
let len = be_bytes.length()
inspect(len, content="8")
}///|
test "method style" {
let x = -42L
// Using method syntax for absolute value
inspect(x.abs(), content="42")
// Binary conversions as methods
inspect(
x.to_be_bytes_local(),
content=(
#|b"\xff\xff\xff\xff\xff\xff\xff\xd6"
),
)
}Int64 is a built-in type. The documentation may not be complete here. You can find all methods and implementations in the core/builtin and core/int64 package.
#deprecated("Use `Int16::from_int64` instead")
fn Int64::to_int16(self : Int64) -> Int16#deprecated("Use `MAX_VALUE` instead")
let max_value : Int64#deprecated("Use `MIN_VALUE` instead")
let min_value : Int64Install
Installed by default