diff options
author | bnewbold <bnewbold@robocracy.org> | 2015-03-03 00:03:14 -0800 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2015-03-03 00:15:30 -0800 |
commit | e62b3c0cf623c1bb4e8a1ec2c8953b9037aea433 (patch) | |
tree | 0153b0ad43eb8ceebea4f1ef80d36e98304a5b2f | |
parent | 4f09c7ff0cd1644e6e638e8746d519d021735356 (diff) | |
download | librambutan-e62b3c0cf623c1bb4e8a1ec2c8953b9037aea433.tar.gz librambutan-e62b3c0cf623c1bb4e8a1ec2c8953b9037aea433.zip |
wirish_math: explicit type casts for round()
This is to squash type promotion warnings and ambiguity (float vs.
double).
A roundf() macro is introduced for use with floats, matching the
POSIX/C99 convention.
-rw-r--r-- | wirish/include/wirish/wirish_math.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/wirish/include/wirish/wirish_math.h b/wirish/include/wirish/wirish_math.h index 39f16a0..ff264dc 100644 --- a/wirish/include/wirish/wirish_math.h +++ b/wirish/include/wirish/wirish_math.h @@ -93,7 +93,8 @@ static inline long map(long value, long fromStart, long fromEnd, #define min(a,b) ((a)<(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b)) #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) -#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) +#define round(x) ((x)>=0?(long)((x)+(double)0.5):(long)((x)-(double)0.5)) +#define roundf(x) ((x)>=0?(long)((x)+(float)0.5):(long)((x)-(float)0.5)) #define radians(deg) ((deg)*DEG_TO_RAD) #define degrees(rad) ((rad)*RAD_TO_DEG) #define sq(x) ((x)*(x)) |