mixed :div ( mixed &ARG , … )
mixed :/ ( mixed &ARG , … )
Takes any number of arguments. Performs division between the rightmost pair of elements, then the second-rightmost, et cetera. Divides the value of the left element by the value of right one. Note that references will modify the values of variables.
Returns a copy of the value the leftmost argument ended up with.
Trying to divide by zero will yield zero.
The table below contains rules for dividing values. Note that these rules are non-symmetrical; swapping the values may yield a different result. The row contains the type of the first (left) value in pair, while the column contains the type of the second (right) value in pair.
NIL | bool | bin | oct | int | hex | float | string | array | dict | |
---|---|---|---|---|---|---|---|---|---|---|
NIL | Arithmetics on NIL values have no effect. | |||||||||
bool | No effect. | Equal to a logical XOR. | If number is non-zero, it's treated as TRUE. Bool division is then performed. | Float is treated as TRUE if absolute value of number is greater-or-equal to 1.0. Bool division is then performed. | String is treated as TRUE if it equals true or contains a non-zero number. Bool division is then performed. | Structure is treated as TRUE if it's non-empty. Bool division is then performed. | ||||
bin | No effect. | Number is set to 0 if bool is FALSE. | No type juggling needed. | Division is performed, the result truncated and then put into integer. | String is converted to number (with regard to base). | Divides by the number of entries in structure. | ||||
oct | ||||||||||
int | ||||||||||
hex | ||||||||||
float | No effect. | Number is set to 0.0 if bool is FALSE. | No type juggling needed. | String is converted to float. | Divides by number of entries in structure. | |||||
string | No effect. | |||||||||
array | Division is performed on each structure element separately. | Division is performed between keys present in both structures. | ||||||||
dict |
# :div example. :set &NUM i10 :set &FLT f10.0 :writeln $NUM s' ' $FLT :div &NUM s'3' :div &FLT s'3' :writeln $NUM s' ' $FLT
wikipage modified on 2014/0601/2317