SultanC
  1. Home
  2. Examples
  3. Numbers

Floating-point numbers

numbers/floating_point.sn
type Pair = { left: f64, right: f64 };

def combine(value: Pair): f64 {
    return (value.left * 2.0) + value.right;
}

def main(): i32 {
    let pair: Pair = { left: 20.0, right: 2.0 };
    let result: f64 = combine(pair);
    if (result == 42.0) { return 42; };
    return 1;
}

Run it

With the interpreter, without compiling:

./build/sultanc run examples/en/numbers/floating_point.sn

Or compile it to an executable:

./build/sultanc examples/en/numbers/floating_point.sn -o build/example && ./build/example

Source on GitHub   All examples