Div.n

From AGI Wiki
Revision as of 17:16, 11 April 2019 by Andrew Korson (talk | contribs) (→‎Remarks)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The div.n command divides a variable by a number.

Syntax

div.n(var vA, byt B);
vA = vA / B;
vA /= B;

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.n vs. divn) 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. Don't do it. EVER. You have been warned.

Example

Code:

<syntaxhighlight lang="agi"> v50 = 85; div.n(v50, 5); [ v50 == 17 v50 /= 5; [ now v50 == 3 </syntaxhighlight>

Technical Information

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

See Also

Mathematical Commands
div.v