summaryrefslogtreecommitdiff
path: root/exercises/097_bit_manipulation.zig
diff options
context:
space:
mode:
authorChris Boesch <chrboesch@noreply.codeberg.org>2025-05-12 19:51:58 +0000
committerChris Boesch <chrboesch@noreply.codeberg.org>2025-05-12 19:51:58 +0000
commit54b2b58b6a25bb3efe42014aa78b70282d84793d (patch)
tree76392070fef9b76c60961658f90d3d6507ffed59 /exercises/097_bit_manipulation.zig
parent377d184cdcf9a5916b0d834cc327ae8dfdf52666 (diff)
parent761fb1a501a73cf553e1ec4ec0d8ab82ff75d6e4 (diff)
Merge pull request 'Exercise 097 - Changed the values for better understanding' (#251) from i210 into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/251
Diffstat (limited to 'exercises/097_bit_manipulation.zig')
-rw-r--r--exercises/097_bit_manipulation.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/exercises/097_bit_manipulation.zig b/exercises/097_bit_manipulation.zig
index 03fc72d..0e64ad7 100644
--- a/exercises/097_bit_manipulation.zig
+++ b/exercises/097_bit_manipulation.zig
@@ -71,9 +71,9 @@ const print = std.debug.print;
pub fn main() !void {
- // As in the example above, we use 1 and 0 as values for x and y
- var x: u8 = 1;
- var y: u8 = 0;
+ // Let us use 1101 and 1011 as values for x and y
+ var x: u8 = 0b1101;
+ var y: u8 = 0b1011;
// Now we swap the values of the two variables by doing xor on them
x ^= y;
@@ -82,7 +82,7 @@ pub fn main() !void {
// What must be written here?
???;
- print("x = {d}; y = {d}\n", .{ x, y });
+ print("x = {b}; y = {b}\n", .{ x, y });
}
// This variable swap takes advantage of the fact that the value resulting