diff options
| author | Chris Boesch <chrboesch@noreply.codeberg.org> | 2026-05-02 19:25:52 +0200 |
|---|---|---|
| committer | Chris Boesch <chrboesch@noreply.codeberg.org> | 2026-05-02 19:25:52 +0200 |
| commit | 1c897e1951d46c8fb95a0f6eaae0221ed816a4a7 (patch) | |
| tree | d47b9840cba67e0bf696d7579062c15b435b55f3 /exercises/060_floats.zig | |
| parent | 6048e6ef21b670b7fab6e9ae0c59a87550aceb6c (diff) | |
adjusted comment to zig 0.16
Diffstat (limited to 'exercises/060_floats.zig')
| -rw-r--r-- | exercises/060_floats.zig | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/exercises/060_floats.zig b/exercises/060_floats.zig index c9d9800..f060810 100644 --- a/exercises/060_floats.zig +++ b/exercises/060_floats.zig @@ -27,10 +27,17 @@ // the types match. Zig does not perform unsafe type coercions // behind your back: // -// var foo: f16 = 5; // NO ERROR +// var foo: f16 = 5; // NO ERROR +// +// A runtime value can coerce to a different type, +// as long as the value is losslessly representable: +// +// var foo: u16 = 5; +// var bar: f16 = foo; // NO ERROR (5 fits in f16) +// +// var foo: u16 = 49876; +// var bar: f16 = foo; // ERROR (49876 not representable in f16) // -// var foo: u16 = 5; // A literal of a different type -// var bar: f16 = foo; // ERROR // // Please fix the two float problems with this program and // display the result as a whole number. |
