Merge pull request #134 from BlueAlmost/bitreverse_comment

corrected @bitReverse for only 1 arg, instead of 2 args
This commit is contained in:
Dave Gauer 2022-09-06 08:08:03 -04:00 committed by GitHub
commit 9d0c2dd0a8
2 changed files with 4 additions and 5 deletions

View file

@ -76,8 +76,7 @@ pub fn main() void {
// Here's a fun one: // Here's a fun one:
// //
// @bitReverse(comptime T: type, integer: T) T // @bitReverse(integer: anytype) T
// * 'T' will be the type of the input and output.
// * 'integer' is the value to reverse. // * 'integer' is the value to reverse.
// * The return value will be the same type with the // * The return value will be the same type with the
// value's bits reversed! // value's bits reversed!
@ -85,6 +84,6 @@ pub fn main() void {
// Now it's your turn. See if you can fix this attempt to use // Now it's your turn. See if you can fix this attempt to use
// this builtin to reverse the bits of a u8 integer. // this builtin to reverse the bits of a u8 integer.
const input: u8 = 0b11110000; const input: u8 = 0b11110000;
const tupni: u8 = @bitReverse(input); const tupni: u8 = @bitReverse(input, tupni);
print("{b:0>8} backwards is {b:0>8}.\n", .{ input, tupni }); print("{b:0>8} backwards is {b:0>8}.\n", .{ input, tupni });
} }

View file

@ -3,6 +3,6 @@
--- ---
> const expected_result: u8 = 0b00010010; > const expected_result: u8 = 0b00010010;
88c88 88c88
< const tupni: u8 = @bitReverse(input); < const tupni: u8 = @bitReverse(input, tupni);
--- ---
> const tupni: u8 = @bitReverse(u8, input); > const tupni: u8 = @bitReverse(input);