summaryrefslogtreecommitdiffstatshomepage
path: root/exercises
diff options
context:
space:
mode:
authorChris Boesch <chrboesch@noreply.codeberg.org>2023-01-14 13:36:33 +0100
committerGitHub <noreply@github.com>2023-01-14 13:36:33 +0100
commit9d3b2b822f61db955eae4bb2fb8e6d6201c9f5b2 (patch)
tree6efe10e0ffc436da64a010da3523e278b4c44372 /exercises
parentf2a4209f6d6b39e148e3e47aa3237ae02c8cadb8 (diff)
parenta165c9425537a607d578e25aacdaf02366a106ac (diff)
Merge branch 'main' into exercise_060_f80
Diffstat (limited to 'exercises')
-rw-r--r--exercises/042_pointers4.zig2
-rw-r--r--exercises/064_builtins.zig6
-rw-r--r--exercises/082_anonymous_structs3.zig4
3 files changed, 5 insertions, 7 deletions
diff --git a/exercises/042_pointers4.zig b/exercises/042_pointers4.zig
index 359a2f1..1f6db70 100644
--- a/exercises/042_pointers4.zig
+++ b/exercises/042_pointers4.zig
@@ -17,7 +17,7 @@ pub fn main() void {
var num: u8 = 1;
var more_nums = [_]u8{ 1, 1, 1, 1 };
- // Let's pass a reference to num to our function and print it:
+ // Let's pass the num reference to our function and print it:
makeFive(&num);
std.debug.print("num: {}, ", .{num});
diff --git a/exercises/064_builtins.zig b/exercises/064_builtins.zig
index 1a0d263..85d1aa7 100644
--- a/exercises/064_builtins.zig
+++ b/exercises/064_builtins.zig
@@ -38,14 +38,12 @@ pub fn main() void {
// Let's try it with a tiny 4-bit integer size to make it clear:
const a: u4 = 0b1101;
const b: u4 = 0b0101;
- var my_result: u4 = undefined;
- var overflowed: bool = undefined;
- overflowed = @addWithOverflow(u4, a, b, &my_result);
+ const my_result = @addWithOverflow(a, b);
// Check out our fancy formatting! b:0>4 means, "print
// as a binary number, zero-pad right-aligned four digits."
// The print() below will produce: "1101 + 0101 = 0010 (true)".
- print("{b:0>4} + {b:0>4} = {b:0>4} ({})", .{ a, b, my_result, overflowed });
+ print("{b:0>4} + {b:0>4} = {b:0>4} ({s})", .{ a, b, my_result[0], if (my_result[1] == 1) "true" else "false" });
// Let's make sense of this answer. The value of 'b' in decimal is 5.
// Let's add 5 to 'a' but go one by one and see where it overflows:
diff --git a/exercises/082_anonymous_structs3.zig b/exercises/082_anonymous_structs3.zig
index 8344321..e5c6839 100644
--- a/exercises/082_anonymous_structs3.zig
+++ b/exercises/082_anonymous_structs3.zig
@@ -4,8 +4,8 @@
//
// .{
// false,
-// @as(u32, 15);
-// @as(i64, 67.12);
+// @as(u32, 15),
+// @as(f64, 67.12)
// }
//
// We call these "tuples", which is a term used by many