fowlerNollVo1aHash() and some other shit
This commit is contained in:
1 parent
ba23e9c0f3
commit
2d3a47a5d8
2 files changed
+31
No files matched your search
@@ -181,6 +181,10 @@ fn inline f32 f32Floor(f32 x) {
|
||||
return (f32)(i - (x < (f32)i));
|
||||
}
|
||||
|
||||
fn inline f32 f32Hypot(f32 dx, f32 dy) {
|
||||
return hypotf(dx, dy);
|
||||
}
|
||||
|
||||
fn inline u32 u32BadRand(u32 *state) {
|
||||
u32 x = *state;
|
||||
x ^= x << 13;
|
||||
@@ -188,3 +192,25 @@ fn inline u32 u32BadRand(u32 *state) {
|
||||
x ^= x << 5;
|
||||
return *state = x;
|
||||
}
|
||||
|
||||
fn u32 f32BitsAsU32(f32 f) {
|
||||
if (f == 0.0f) f = 0.0f; // -0 -> +0
|
||||
u32 u;
|
||||
memcpy(&u, &f, 4);
|
||||
return u;
|
||||
}
|
||||
|
||||
fn inline u32 f32BitsAsEpsilonU32(f32 f, f32 epsilon) {
|
||||
return f32BitsAsU32(truncf(f / epsilon) * epsilon);
|
||||
}
|
||||
|
||||
fn inline i32 f32RoundByN(f32 x, u32 n) {
|
||||
return (i32)(roundf(x / (f32)n) * (f32)n);
|
||||
}
|
||||
|
||||
fn u32 fowlerNollVo1aHash(u32 h, const void* data, u32 n) {
|
||||
const u8 *p = data;
|
||||
while (n--) { h ^= *p++; h *= 16777619u; }
|
||||
return h;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user