GOOC - Game Oriented Object C
GOOC - Game Oriented Object C
7.2. Arithmetic Operators
7.2. Arithmetic Operators
GOOC provides operators for standard arithmetic operations: addition, subtraction, multiplication, and division, along with modular division and negation. Usage of these operators is pretty straightforward.
Integer division of positive values truncates towards zero, so 5/3 is 1. However, if either operand is negative, then I DONT KNOW FIXME
You use the modulus operator % to obtain the remainder produced by dividing its two operands. You put the operands on either side of the operator, and it does matter which operand goes on which side: 3 % 5 and 5 % 3 do not have the same result. Modular division returns the remainder produced after performing integer division on the two operands. The operands must be of a primitive integer type. Division of two registers on the MIPS R3000A chip takes about 36x the amount of time compared to addition of two registers, so usage of the modulus and division operators should be kept at minimum in source code.
The MIPS R3000A uses twos-complement arithmetic, meaning the most negative value is farther away from zero than the most positive value. Negating the minimum integer value therefore has no effect on its value.
You can also apply a positive operator to an expressions, which simply returns the expression and has no effect on program operation.