Subv: Difference between revisions

From Sierra Wiki
Jump to navigationJump to search
en>Andrew Korson
Created page with "The '''subv''' command subtracts the value of one variable from another and stores the result in the first variable. == Syntax == subv(var vA, var..."
 
Andrew Branscom (talk | contribs)
m 1 revision imported
 
(No difference)

Latest revision as of 16:04, 3 April 2025

The subv command subtracts the value of one variable from another and stores the result in the first variable.

Syntax

subv(var vA, var vB);
vA = vA - vB;
vA -= vB;

Remarks

Because variables are 8 bit unsigned numbers, if the result of the subtraction is less than 0, the result 'wraps around'. For example, if v50 currently equals 20 and v51 equals 25, the statement:

subv(v50, v51);

will result in a value for v50 of 251 (20 - 25 = -5; -5 + 256 = 251).

Possible Errors

None.

Example

Code:
v50 = 75;
v51 = 60;
subv(v50, v51);  [ v50 now equals 15
v50 = v50 - v51; [ v50 now equals 211 (-45 + 256)
v50 -= v51;      [ v50 now equals 151

Technical Information

Required Interpreter Version: Available in all AGI versions.
Byte-Code Value: 8 (0x08 hex)

See Also

Mathematical Commands
subn