Revert "random: Do math as unsigned"

This reverts commit 0902e29f49.

Just doesn't work - overflows.
This commit is contained in:
Fabian Boehm 2023-02-20 19:56:34 +01:00
parent ad22bf9387
commit e3b04118b1

View File

@ -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;