navid/haze / cb1bac46fbd9fca0f0e2a401590740b0840b47821983a25743fc29c1572577d9 / samples/baseline_2.9/floats.hz

floats.hz

← samples/baseline_2.9 · 535 bytes · raw · download

// f64 literals, arithmetic, comparisons, records, lists, and numeric casts.

type Vec {
    x f64
    y f64
}

fn add(a f64, b f64) f64 => a + b

fn main() {
    var v = Vec{ x = 1.5, y = 2.5 }
    print(v.x)
    print(v.y)
    print(add(v.x, v.y))

    var values = [1.0, 2.5, 3.75]
    print(values[2])

    print(1.5 + 2.25)
    print(3.0 * 1.5)
    print(1.0 / 4.0)
    print(-1.5)
    print(1.5 < 2.5)
    print(1.5 == 1.5)

    var count u64 = 3
    print(cast[f64](count))
    print(cast[u64](3.9))
    print(cast[i32](3.9))
}