Add, subtract, multiply and divide work strictly with integers. They always return integers. (divide 2 3) -> 0
+, -, * and / might return a float. (/ 2 3) -> 0.6666666666
No one can ever guess the difference and as such you might except some very sneaky bugs coming from that. Since floats were added only recently [and there isn't much info on them anyway], I think we should slightly change math functions arguments
(math_function {literal or symbolic} [type='int32] args) --> result of applying respective operator to each argument.
type argument defines how operators work with arguments. Correct values are:
int32
float
int32 will return an integer as the result.
float will return a float as the result.
This was done for backwards compatibility. Prior to floating point support, people used add
, subtract
, etc. and expected it to return integers. The new function +
, -
, etc. now work on floats and return floats.
Note also that you can write the function you propose for your own use.