Add more xorshift utilities
Release / release (push) Successful in 2s

This commit is contained in:
2026-09-06 13:40:13 +01:00
parent c83f9333de
commit 9055c5c825
3 changed files with 31 additions and 0 deletions
+24
View File
@@ -79,6 +79,30 @@ u64 wpPrngXorshift256p(WpXor256State *state) {
return result;
}
u64 wpPrngXorshift256InRange(WpXor256State *state, u64 start, u64 end) {
return wpPrngXorshift256(state) % (end - start) + start;
}
u64 wpPrngXorshift256ssInRange(WpXor256State *state, u64 start, u64 end) {
return wpPrngXorshift256ss(state) % (end - start) + start;
}
u64 wpPrngXorshift256pInRange(WpXor256State *state, u64 start, u64 end) {
return wpPrngXorshift256p(state) % (end - start) + start;
}
u64 wpPrngXorshift256Choice(WpXor256State *state, u64 available_choices) {
return wpPrngXorshift256(state) % available_choices;
}
u64 wpPrngXorshift256ssChoice(WpXor256State *state, u64 available_choices) {
return wpPrngXorshift256ss(state) % available_choices;
}
u64 wpPrngXorshift256pChoice(WpXor256State *state, u64 available_choices) {
return wpPrngXorshift256p(state) % available_choices;
}
wp_intern u64 split_mix_64(SplitMix64State *state) {
state->seed += 0x9E3779B97f4A7C15;
+6
View File
@@ -23,6 +23,12 @@ WpXor256State wpPrngXorshiftInitWithSeed(u64 seed);
u64 wpPrngXorshift256(WpXor256State *state);
u64 wpPrngXorshift256ss(WpXor256State *state);
u64 wpPrngXorshift256p(WpXor256State *state);
u64 wpPrngXorshift256InRange(WpXor256State *state, u64 start, u64 end);
u64 wpPrngXorshift256ssInRange(WpXor256State *state, u64 start, u64 end);
u64 wpPrngXorshift256pInRange(WpXor256State *state, u64 start, u64 end);
u64 wpPrngXorshift256Choice(WpXor256State *state, u64 available_choices);
u64 wpPrngXorshift256ssChoice(WpXor256State *state, u64 available_choices);
u64 wpPrngXorshift256pChoice(WpXor256State *state, u64 available_choices);
#ifdef WP_PLATFORM_CPP
END_C_LINKAGE