Difference between revisions of "Div.v"

From AGI Wiki
Jump to navigationJump to search
(Created page with "The '''div.v''' command divides a variable by another variable, and stores the result in the first. == Syntax == div.v(var vA, var vB);<br...")
 
 
Line 10: Line 10:
  
 
The results of the division are rounded down (i.e. the result is truncated).
 
The results of the division are rounded down (i.e. the result is truncated).
 +
 +
Note that this command uses the 'dot' notation (i.e. '''div.v''' vs. '''divv''')  unlike the original set of mathematical commands.
  
 
== Possible Errors ==
 
== Possible Errors ==

Latest revision as of 17:17, 11 April 2019

The div.v command divides a variable by another variable, and stores the result in the first.

Syntax

div.v(var vA, var vB);
vA = vA / vB;
vA /= vB;

Remarks

The results of the division are rounded down (i.e. the result is truncated).

Note that this command uses the 'dot' notation (i.e. div.v vs. divv) unlike the original set of mathematical commands.

Possible Errors

AGI does not check for a divide by zero error. If an attempt is made to divide by zero, AGI will crash.

Example

Code:
v50 = 77;
v51 = 7;
div.v(v50, v51); [ v50 now equals 11
v50 = v50 / v51; [ v50 now equals 1
v50 /= v51;      [ v50 now equals 0

Technical Information

Required Interpreter Version: Available in version 2.411 and above.
Byte-Code Value: 168 (0xA8 hex)

See Also

Mathematical Commands
div.n