mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 12:04:39 +08:00
Revert "random: Do math as unsigned"
This reverts commit 0902e29f49
.
Just doesn't work - overflows.
This commit is contained in:
parent
ad22bf9387
commit
e3b04118b1
|
@ -165,7 +165,10 @@ pub fn random(
|
|||
};
|
||||
|
||||
// Safe because end was a valid i64 and the result here is in the range start..=end.
|
||||
let result: i64 = (start as u64 + (rand * step) as u64) as i64;
|
||||
let result: i64 = start
|
||||
.checked_add_unsigned(rand * step)
|
||||
.and_then(|x| x.try_into().ok())
|
||||
.unwrap();
|
||||
|
||||
streams.out.append(sprintf!(L!("%d\n"), result));
|
||||
return STATUS_CMD_OK;
|
||||
|
|
Loading…
Reference in New Issue
Block a user