mirror of
https://codeberg.org/ziglings/exercises.git
synced 2025-11-05 05:05:36 +00:00
Merge pull request 'Fixed description to decimal and scientific notation' (#312) from i311 into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/312
This commit is contained in:
commit
b72bcd7e47
|
|
@ -45,9 +45,10 @@ pub fn main() void {
|
||||||
// conversion of 0.453592 kg to the pound.
|
// conversion of 0.453592 kg to the pound.
|
||||||
const shuttle_weight: f16 = 0.453592 * 4480e3;
|
const shuttle_weight: f16 = 0.453592 * 4480e3;
|
||||||
|
|
||||||
// By default, float values are formatted in scientific
|
// By default, float values are formatted in standard decimal
|
||||||
// notation. Try experimenting with '{d}' and '{d:.3}' to see
|
// notation. Experiment with '{d}' and '{d:.3}' to see how
|
||||||
// how decimal formatting works.
|
// decimal formatting works, or try '{e}' and '{e:.3}' for
|
||||||
|
// scientific notation.
|
||||||
print("Shuttle liftoff weight: {d:.0} metric tons\n", .{shuttle_weight / 1e3});
|
print("Shuttle liftoff weight: {d:.0} metric tons\n", .{shuttle_weight / 1e3});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
--- exercises/060_floats.zig 2025-10-03 13:28:03.092371247 +0200
|
--- exercises/060_floats.zig 2025-10-17 17:58:44.811502880 +0200
|
||||||
+++ answers/060_floats.zig 2025-10-03 13:27:40.842926774 +0200
|
+++ answers/060_floats.zig 2025-10-17 17:57:39.227157388 +0200
|
||||||
@@ -43,7 +43,7 @@
|
@@ -43,7 +43,7 @@
|
||||||
//
|
//
|
||||||
// We'll convert this weight from pounds to metric units at a
|
// We'll convert this weight from pounds to metric units at a
|
||||||
|
|
@ -7,5 +7,5 @@
|
||||||
- const shuttle_weight: f16 = 0.453592 * 4480e3;
|
- const shuttle_weight: f16 = 0.453592 * 4480e3;
|
||||||
+ const shuttle_weight: f32 = 0.453592 * 4.480e6;
|
+ const shuttle_weight: f32 = 0.453592 * 4.480e6;
|
||||||
|
|
||||||
// By default, float values are formatted in scientific
|
// By default, float values are formatted in standard decimal
|
||||||
// notation. Try experimenting with '{d}' and '{d:.3}' to see
|
// notation. Experiment with '{d}' and '{d:.3}' to see how
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user