From: Charlie Brej Date: Mon, 25 Jan 2010 20:36:35 +0000 (+0000) Subject: [script] Use floor when implementing Int X-Git-Tag: 0.8.0~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=437be1c6db2fb565adbcb0aad1ad7c35cdf9295d;p=thirdparty%2Fplymouth.git [script] Use floor when implementing Int Previously the Math.Int function converted to int and back to double. The floor function works larger than those represented by integers and it correctly handles NaN and Inf. --- diff --git a/src/plugins/splash/script/script-lib-math.c b/src/plugins/splash/script/script-lib-math.c index e0782438..383fe46f 100644 --- a/src/plugins/splash/script/script-lib-math.c +++ b/src/plugins/splash/script/script-lib-math.c @@ -61,11 +61,6 @@ static script_return_t script_lib_math_random (script_state_t *state, return script_return_obj (script_obj_new_number (reply_double)); } -static double double_to_int (double value) -{ - return (double) (int) value; -} - script_lib_math_data_t *script_lib_math_setup (script_state_t *state) { script_lib_math_data_t *data = malloc (sizeof (script_lib_math_data_t)); @@ -105,7 +100,7 @@ script_lib_math_data_t *script_lib_math_setup (script_state_t *state) script_add_native_function (math_hash, "Int", script_lib_math_double_from_double_function, - double_to_int, + floor, "value", NULL); script_add_native_function (math_hash,