mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-12-22 14:03:10 -05:00
corrected @bitReverse for only 1 arg, instead of 2 args
This commit is contained in:
parent
2656b26c83
commit
b69a297e32
2 changed files with 4 additions and 5 deletions
|
@ -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 });
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue