JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
* main.c (enginedots, bangdots): combined into a single dot type.
[vor.git] / float.h
1 #ifndef VOR_FLOAT_H
2 #define VOR_FLOAT_H
3
4 #include <math.h>
5
6 static inline int
7 fclip(float f, float max)
8 {
9         return f < 0 || (float)f >= (float)max;
10 }
11
12 static inline float
13 fwrap(float f, float max)
14 {
15         if((float)f >= (float)max) f = (float)f - (float)max;
16         else if(f < 0) {
17                 f += max;
18                 if((float)f >= (float)max) f = nextafterf(f, 0);
19         }
20         return f;
21 }
22
23 #endif // VOR_FLOAT_H