elm_macros: fix for lack of precision with double due to order of operation.
authorj_yong.hwang <j_yong.hwang@samsung.com>
Tue, 4 Aug 2015 14:08:50 +0000 (16:08 +0200)
committerCedric BAIL <cedric@osg.samsung.com>
Tue, 4 Aug 2015 14:49:44 +0000 (16:49 +0200)
Summary:
The numerical formula below is calculated with the double type.
-> ELM_SCALE_SIZE(x) (int)(((double)(x) / elm_app_base_scale_get()) * elm_config_scale_get())

But if number of significant figure of the return value goes over 15, the epsilon error will happen.
Because of that, it is better to divide to do later.

Reviewers: woohyun, cedric

Reviewed By: cedric

Differential Revision: https://phab.enlightenment.org/D2900

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/lib/elm_macros.h

index c786c68..61b3377 100644 (file)
@@ -1,7 +1,7 @@
 /* handy macros */
 #define ELM_RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && (((x) + (w)) > (xx)) && (((y) + (h)) > (yy)))
 #define ELM_PI 3.14159265358979323846
-#define ELM_SCALE_SIZE(x) (int)(((double)(x) / elm_app_base_scale_get()) * elm_config_scale_get())
+#define ELM_SCALE_SIZE(x) (int)(((double)(x) * elm_config_scale_get()) / elm_app_base_scale_get())
 
 // checks if the point(xx, yy) stays out of the rectangle(x, y, w, h) area.
 #define ELM_RECTS_POINT_OUT(x, y, w, h, xx, yy) (((xx) < (x)) || ((yy) < (y)) || ((xx) > ((x) + (w))) || ((yy) > ((y) + (h))))