Howdy again everyone.
I am trying to get the output of an integer shifted 8 bits to the left.
This works:
const std = @import("std");
pub fn main() !void {
const num = 42;
const flipped = num << 8;
std.debug.print("{d}\n", .{flipped}); // == 10752
}
But for some reason I get an error with this:
const std = @import("std");
pub fn main() !void {
const nums = [1]u8{ 42 };
const flipped = nums[0] << 8;
std.debug.print("{d}\n", .{flipped});
}
With the error when I compile:
error: type 'u3' cannot represent integer value '8'
Is this a glitch, or is there something I am not getting? I normally donât shift bits in any of my projects so this is all new to me. Any tips, hints, and explanations would be greatly appreciated . As usual, thank you again for the help!