Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion library/core/src/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ macro_rules! impl_primitive {
fn sample(&self, source: &mut (impl RandomSource + ?Sized)) -> $t {
let mut bytes = (0 as $t).to_ne_bytes();
source.fill_bytes(&mut bytes);
<$t>::from_ne_bytes(bytes)
// Always use little-endian for reproducibility. Since the vast majority of code is
// mainly or exclusively tested on LE targets, giving different PRNG results for the
// same seed on BE targets is a serious portability hazard.
<$t>::from_le_bytes(bytes)
}
}
};
Expand Down
Loading