aboutsummaryrefslogtreecommitdiffstats
path: root/wirish/include
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2015-03-03 00:03:14 -0800
committerbnewbold <bnewbold@robocracy.org>2015-03-03 00:15:30 -0800
commite62b3c0cf623c1bb4e8a1ec2c8953b9037aea433 (patch)
tree0153b0ad43eb8ceebea4f1ef80d36e98304a5b2f /wirish/include
parent4f09c7ff0cd1644e6e638e8746d519d021735356 (diff)
downloadlibrambutan-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.
Diffstat (limited to 'wirish/include')
-rw-r--r--wirish/include/wirish/wirish_math.h3
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))