Unlike other "integer" functions, gcd() and lcm() return integer types from double arguments
Reported by Ross Piltz
BUG DESCRIPTION:
----------------
Functions round(), factorial(), factor(), primes(), [n,d]=rat(), ceil(), fix(), floor(), int(), round() all return integer values using double type if the arguments are double. Some of the above do not accept integer type arguments, others complain if the double type value is not close to an integer, others appears to round down the double values to integer values. Only gcd() and lcm() return integer types if given double type arguments.
This may seem trivial, but combined with Bug#15016 (mixed arithmetic converts double type to integer type) it can produce some very insidious bugs, such as: gcd([3,4])+0.5 equals 1 instead of the intended 1.5.
This happens for 6.0.0, 5.2.2, and presumably all other SCILAB versions.
HOW TO REPRODUCE THE BUG:
-------------------------
--> gcd([2.0,4.0])
ans = 2
--> gcd(int32([2,4]))
ans = 2
--> round(int32(2))
ans = 2
--> round(2.0)
ans = 2.
--> factorial(3)
ans = 6.
--> factorial(int32(3))
at line 14 of function factorial ( C:\Program Files\scilab-6.0.0\modules\elementary_functions\macros\factorial.sci line 26 )
factorial: Wrong value for input argument #1: Scalar/vector/matrix/hypermatrix of positive integers expected.