Open gheskett opened 2 years ago
also roundf
should be renamed to lroundf
so that it can be used in constants
https://github.com/FreyaHolmer/Mathfs/blob/master/Mathfs.cs#L811
example of some helpful funcs
pow
should be powf
and log
should be logf
to conform with C standard library naming (https://en.cppreference.com/w/c/numeric/math/pow and https://en.cppreference.com/w/c/numeric/math/log). However, they won't be able to be evaluated at constant time like cozies said because of the repo using -ffreestanding
as a compiler flag. There are ways around it, such as using __builtin_powf
if the value is a constant.
Here's an example of using __builtin_logf for constant evaluation: https://godbolt.org/z/33Ph9j4b8
Here's a link to a repo with some fast approximate math function implementations, some of them use bit twiddling on floats so they're pretty fast: https://github.com/pmineiro/fastapprox
Thoughts on supporting hash tables?
I think hash tables are out of place in the repo because they would need to go hand-in-hand with a memory allocation scheme. A general hash function on the other hand could be nice, xxHash is a good option for that imo: https://github.com/Cyan4973/xxHash
Moving to 2.2
Notable function additions:
u32 random_u32(void)
f32 pow(f32 num, f32 exponent)
f32 log(f32 num, f32 base)
Maybe also consider adding inline functions for stuff like
clamp
,sign
,min
,max
, etc.