Numbers
Integers

Integers in Gera specifically are signed 64-bit integers, with the smallest possible value being -9223372036854775808 and the largest possible value being 9223372036854775807. Simply write the value to create an integer value. Integer arithmetic is defined to be wrap around on overflow.

mod example

proc main() {
val a = 5
val b = 10
}

Floats

Floats in Gera specifically are double-precision 64-bit binary format (IEEE 754) floats. To create a float value, write the number, making sure to include the decimal point. Number literals without decimal points are interpreted as integers.

mod example

proc main() {
val a = 5.0
val b = 3.14
val c = 0.345
}

Operations

The following operations can be used with both integers and floats (although they may not both be involved in the same operation):

mod example

use std::io::println

proc main() {
val a = 5
val b = 3
val c = a % b
val d = c + 5
println(d) // prints '7'
println(d < a) // prints 'false'
}

Conversions

Numbers can be converted to integers and floats using the built-in as_int- and as_flt-procedures. Note that as_int truncates floats, rounding them towards zero.

mod example

proc main() {
val pi = 3.1415
println(as_int(pi)) // prints '3'
println(as_flt(25) + 0.25) // prints '25.25'
}