]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[script] Use floor when implementing Int
authorCharlie Brej <cbrej@cs.man.ac.uk>
Mon, 25 Jan 2010 20:36:35 +0000 (20:36 +0000)
committerroot <cbrej@cs.man.ac.uk>
Mon, 25 Jan 2010 20:36:35 +0000 (20:36 +0000)
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.

src/plugins/splash/script/script-lib-math.c

index e0782438407f0bd9dc5782943fec64a9a3c4916d..383fe46f6606c0b65cc108282e5eded02def9868 100644 (file)
@@ -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,