mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 00:52:52 +00:00
std.hash.int: restore previous behavior
In the parent commit, I handled odd bit sizes by upcasting and truncating. However it seems the else branch is intended to handle those cases instead, so this commit reverts that behavior.
This commit is contained in:
parent
5ad44c14b0
commit
d09fd249c0
@ -51,12 +51,8 @@ pub fn int(input: anytype) @TypeOf(input) {
|
|||||||
const Unsigned = @Type(.{ .int = .{ .signedness = .unsigned, .bits = info.bits } });
|
const Unsigned = @Type(.{ .int = .{ .signedness = .unsigned, .bits = info.bits } });
|
||||||
const casted: Unsigned = @bitCast(input);
|
const casted: Unsigned = @bitCast(input);
|
||||||
return @bitCast(int(casted));
|
return @bitCast(int(casted));
|
||||||
} else if (info.bits < 16) {
|
} else if (info.bits < 4) {
|
||||||
return @truncate(int(@as(u16, input)));
|
return @truncate(int(@as(u4, input)));
|
||||||
} else if (info.bits < 32) {
|
|
||||||
return @truncate(int(@as(u32, input)));
|
|
||||||
} else if (info.bits < 64) {
|
|
||||||
return @truncate(int(@as(u64, input)));
|
|
||||||
}
|
}
|
||||||
var x = input;
|
var x = input;
|
||||||
switch (info.bits) {
|
switch (info.bits) {
|
||||||
|
Loading…
Reference in New Issue
Block a user