mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
random: Do math as unsigned
Hahah bits go brrrr
This commit is contained in:
parent
77a474ee37
commit
0902e29f49
1 changed files with 1 additions and 4 deletions
|
@ -165,10 +165,7 @@ pub fn random(
|
|||
};
|
||||
|
||||
// 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;
|
||||
|
|
Loading…
Reference in a new issue