···2727// the types match. Zig does not perform unsafe type coercions
2828// behind your back:
2929//
3030-// var foo: f16 = 5; // NO ERROR
3030+// var foo: f16 = 5; // NO ERROR
3131//
3232-// var foo: u16 = 5; // A literal of a different type
3333-// var bar: f16 = foo; // ERROR
3232+// A runtime value can coerce to a different type,
3333+// as long as the value is losslessly representable:
3434+//
3535+// var foo: u16 = 5;
3636+// var bar: f16 = foo; // NO ERROR (5 fits in f16)
3737+//
3838+// var foo: u16 = 49876;
3939+// var bar: f16 = foo; // ERROR (49876 not representable in f16)
4040+//
3441//
3542// Please fix the two float problems with this program and
3643// display the result as a whole number.
+5-5
patches/patches/060_floats.patch
···11---- exercises/060_floats.zig 2026-04-03 14:40:17.582344768 +0200
22-+++ answers/060_floats.zig 2026-04-03 14:49:26.997886326 +0200
33-@@ -43,7 +43,7 @@
11+--- exercises/060_floats.zig 2026-05-02 19:22:46.225370223 +0200
22++++ answers/060_floats.zig 2026-05-02 19:22:47.523142218 +0200
33+@@ -50,7 +50,7 @@
44 //
55 // We'll convert this weight from pounds to metric units at a
66 // conversion of 0.453592 kg to the pound.
···991010 // By default, float values are formatted in standard decimal
1111 // notation. Experiment with '{d}' and '{d:.3}' to see how
1212-@@ -51,7 +51,7 @@
1212+@@ -58,7 +58,7 @@
1313 // scientific notation.
1414 // NOTE: The weight of the shuttle is a huge number, a scientific notation
1515 // may be more appropriate.
1616- print("Shuttle liftoff weight: {d:.0} metric tons\n", .{shuttle_weight / 1e3});
1717+ print("Shuttle liftoff weight: {e:.3} metric tons\n", .{shuttle_weight / 1e3});
1818 }
1919-1919+2020 // Floating further: