Numbers
Donna has Int and Float.
let count = 3
let ratio = 0.5
Use Int for whole numbers and Float for decimal values.
fn next(value: Int) -> Int:
value + 1
fn half(value: Float) -> Float:
value /. 2.0
Underscores can group digits.
echo 1_000_000
echo 10_000.01
Integer literals can be binary, octal, or hex.
echo 0b00001111
echo 0o17
echo 0xF
Those all print the same value: 15.
Floats support scientific notation.
echo 7.0e7
echo 3.0e-4
Convert numbers to strings with the standard library when you need text output.
import donna/string
pub fn main() -> Nil:
let total = 1 + 2 + 3
echo string.from_int(total)