From e62b3c0cf623c1bb4e8a1ec2c8953b9037aea433 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Tue, 3 Mar 2015 00:03:14 -0800 Subject: 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. --- wirish/include/wirish/wirish_math.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'wirish') 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)) -- cgit v1.2.3