View source for Gamevar operators - EDukeWiki

# View source for Gamevar operators

← Gamevar operators

You do not have permission to edit this page, for the following reasons:

- The action you have requested is limited to users in the group: Users.
- You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

<'''operator'''>'''var''' <gamevar> <value><br> <'''operator'''>'''varvar''' <gamevar> <value> Gamevar operators are commands that perform various mathematical and bitwise logical operations on [[gamevar]]s. The first argument must be a writable gamevar and is taken as the destination as well and the first operand (2-address code). For example: setvar temp 1 // assigns a value of 1 to the gamevar ''temp''. addvar temp 1 // adds 1 to ''temp'', causing its value to become 2. mulvar temp 2 // multiplies ''temp'' by 2, causing its value to become 4. {| {{prettytable}} !Operator!!C/C++!!Math!!Description!!Notes!! |- |set |<code>=</code> |= |assignment |- |add |<code><nowiki>+</nowiki></code> |<nowiki>+</nowiki> |addition | |- |sub |<code><nowiki>-</nowiki></code> |<nowiki>&ndash;</nowiki> |subtraction | |- |mul |<code>*</code> |&times; |multiplication | |- |div |<code>/</code> |&#247; |division with rounding toward 0 for nonnegative dividends |Ensure that <value> does not equal 0 at any time. '''The rounding behavior is undefined for negative dividends.''' |- |mod |<code>%</code> | |[[Wikipedia:Modulo operation|modulo]], remainder |Ensure that <value> does not equal 0 at any time; sign of the result is that of left hand side operand (dividend). |- |and |<code>&</code> | |[[Wikipedia:Bitwise operation|bitwise]] AND |The bits in the result are set only if they were set in both of the values being operated on. Ex. (all numbers are [[Wikipedia:Binary numeral system|base-2]]): 01001010 AND 11110100 is 01000000 |- |or |<code><nowiki>|</nowiki></code> | |[[Wikipedia:Bitwise operation|bitwise]] OR |The bits in the result are set only if they were set in either of the values being operated on. Ex.: 01001010 OR 11110100 is 11111110 |- |xor |<code>^</code> | |[[Wikipedia:Bitwise operation|bitwise]] XOR |The bits in the result are set if only one of the values being operated on has those bits set. Ex.: 01001010 XOR 11110100 is 10111110 |} {{varsuffix}} [[Category:Gamevar manipulation]]

Templates used on this page:

- Template:Prettytable (view source)
- Template:Varsuffix (view source)

Return to Gamevar operators.

Retrieved from "http://wiki.eduke32.com/wiki/Gamevar_operators"