Table of Contents
addDescriptionAdd two numbers. Function prototypevariant add <variant:Var1> <variant:Var2> Arguments
If the type of arg1 is not equal to that of arg2, the ordering of the arguments may change the result of calls to
add . See Algebra of variables of dissimilar types.
Return valueThe sum of arg1 and arg2, in the data type of arg1. Examplefloat f set f 50.1 echo <zs:add f 20> … the output of which is written to the event log by echo as: 70.1 CommentsAlgebra of variables of dissimilar types
If the type of arg2 is different to that of arg1, arg2 will be typecast to the type of arg1. Thus, in certain circumstances, the the result of For example, consider the case of adding a float (f = 4.5) and an integer (i = 4): float f int i set f 4.5 set i 4 echo <zs: add f i> // 'f' goes first, so comparing as floats echo <zs: add i f> // 'i' goes first, so comparing as integers The result of this code is: 8.5 8
In the first addition in the above script (
In the second addition in the above script ( The moral of the story is: when performing algebraic operations on variables, consider the type of the variables when deciding the argument order. See alsoExcept where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
|