my ziglings
0

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request 'Changed exercise 60 to require change of format' (#384) from markuxcu/exercises:fix-060 into main

Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/384

Chris Boesch (Apr 7, 2026, 9:25 AM +0200) b225538a 3574fd3a

+15 -4
+1 -1
build.zig
··· 1010 1010 }, 1011 1011 .{ 1012 1012 .main_file = "060_floats.zig", 1013 - .output = "Shuttle liftoff weight: 2032 metric tons", 1013 + .output = "Shuttle liftoff weight: 2.032e3 metric tons", 1014 1014 }, 1015 1015 .{ 1016 1016 .main_file = "061_coercions.zig",
+2
exercises/060_floats.zig
··· 49 49 // notation. Experiment with '{d}' and '{d:.3}' to see how 50 50 // decimal formatting works, or try '{e}' and '{e:.3}' for 51 51 // scientific notation. 52 + // NOTE: The weight of the shuttle is a huge number, a scientific notation 53 + // may be more appropriate. 52 54 print("Shuttle liftoff weight: {d:.0} metric tons\n", .{shuttle_weight / 1e3}); 53 55 } 54 56
+12 -3
patches/patches/060_floats.patch
··· 1 - --- exercises/060_floats.zig 2025-10-17 17:58:44.811502880 +0200 2 - +++ answers/060_floats.zig 2025-10-17 17:57:39.227157388 +0200 1 + --- exercises/060_floats.zig 2026-04-03 14:40:17.582344768 +0200 2 + +++ answers/060_floats.zig 2026-04-03 14:49:26.997886326 +0200 3 3 @@ -43,7 +43,7 @@ 4 4 // 5 5 // We'll convert this weight from pounds to metric units at a 6 6 // conversion of 0.453592 kg to the pound. 7 7 - const shuttle_weight: f16 = 0.453592 * 4480e3; 8 - + const shuttle_weight: f32 = 0.453592 * 4.480e6; 8 + + const shuttle_weight: f32 = 0.453592 * 4480e3; 9 9 10 10 // By default, float values are formatted in standard decimal 11 11 // notation. Experiment with '{d}' and '{d:.3}' to see how 12 + @@ -51,7 +51,7 @@ 13 + // scientific notation. 14 + // NOTE: The weight of the shuttle is a huge number, a scientific notation 15 + // may be more appropriate. 16 + - print("Shuttle liftoff weight: {d:.0} metric tons\n", .{shuttle_weight / 1e3}); 17 + + print("Shuttle liftoff weight: {e:.3} metric tons\n", .{shuttle_weight / 1e3}); 18 + } 19 + 20 + // Floating further: