aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/exercises/064_builtins.zig
diff options
context:
space:
mode:
authorChris Boesch <chrboesch@noreply.codeberg.org>2023-01-21 14:41:35 +0100
committerGitHub <noreply@github.com>2023-01-21 14:41:35 +0100
commit68af87518f1b56170bb6c526fe0770c3c20ebabb (patch)
tree9e62c59d47a7db243fa9cb0a7b171c66cf58416b /exercises/064_builtins.zig
parente978b09a0ac98919cbad5fe89d2e8e8adbea5a1c (diff)
parent69a02c5ec4f279feb750e97cf079525947c944e7 (diff)
Merge branch 'main' into check_output_len
Diffstat (limited to 'exercises/064_builtins.zig')
-rw-r--r--exercises/064_builtins.zig6
1 files changed, 2 insertions, 4 deletions
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: