mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 12:21:19 -03:00
random: Do math as unsigned
Hahah bits go brrrr
This commit is contained in:
@@ -165,10 +165,7 @@ fn parse<T: PrimInt>(
|
||||
};
|
||||
|
||||
// Safe because end was a valid i64 and the result here is in the range start..=end.
|
||||
let result: i64 = start
|
||||
.checked_add_unsigned(rand * step)
|
||||
.and_then(|x| x.try_into().ok())
|
||||
.unwrap();
|
||||
let result: i64 = (start as u64 + (rand * step) as u64) as i64;
|
||||
|
||||
streams.out.append(sprintf!(L!("%d\n"), result));
|
||||
return STATUS_CMD_OK;
|
||||
|
||||
Reference in New Issue
Block a user