Skip to content

Numbers

Integer is an arbitrary-precision BEAM integer. Float is a BEAM float. They do not convert to each other; you call gale_std.number.float when you need a float.

module numbers
pub fn add(left: Integer, right: Integer) -> Integer {
left + right
}
pub fn half(x: Float) -> Float {
x / 2.0
}
pub fn from_int(n: Integer) -> Float {
gale_std.number.float(n)
}

Mixing the two in one operator is a type error:

pub fn mixed() -> Float {
1 + 1.0
}