PropertyValue
rdfs:label
  • Arithmetic operator
rdfs:comment
  • "In programming activities, [an] arithmetic operator [is] a symbol representing an arithmetic calculation or process.
  • The arithmetic operators of NWScript perform basic arithmetic on integers, floating point numbers, and vectors. They consist of +, - (unary), - (binary), *, /, and %. Several of these operators tend to be readily recognizable, as they correspond well to standard arithmetic notation. That is, + performs addition, - in front of a number performs negation (converting positive to negative and vice versa), - between two numbers subtracts the second from the first, and / between two numbers divides the first by the second. (In this context, "number" can be an explicit number, a variable or function with a numeric value, or an expression that evaluates to a number.) Of the remaining arithmetic operators, * performs multiplication, while % is the modulus operator, which produces the remainder when
dcterms:subject
abstract
  • The arithmetic operators of NWScript perform basic arithmetic on integers, floating point numbers, and vectors. They consist of +, - (unary), - (binary), *, /, and %. Several of these operators tend to be readily recognizable, as they correspond well to standard arithmetic notation. That is, + performs addition, - in front of a number performs negation (converting positive to negative and vice versa), - between two numbers subtracts the second from the first, and / between two numbers divides the first by the second. (In this context, "number" can be an explicit number, a variable or function with a numeric value, or an expression that evaluates to a number.) Of the remaining arithmetic operators, * performs multiplication, while % is the modulus operator, which produces the remainder when the integer to its left is divided by the one to its right (unlike the other arithmetic operators, modulus is only defined for integers). Aside from the modulus operator, NWScript allows arithmetic operators to operate on a mix of integers and floating point numbers. The result will be an integer if only integers are involved, and a floating point number otherwise. This is most significant with regards to the division operator, as integer division drops the remainder, while floating point division is carried out to as many decimal places as can be represented. Vectors can be used in place of integers and floats in several cases. The addition and subtraction operators allow both operands to be vectors (one cannot add an integer to a vector though), and similarly the negation operator can operate on a single vector. Multiplication can be performed between a floating point (scalar) number and a vector, with the number multiplying each component of the vector. The priorities of the arithmetic operators follow the standard order of operations, with multiplication, division, and modulus performed before addition and subtraction. Within these two categories, operations are performed left-to-right.
  • "In programming activities, [an] arithmetic operator [is] a symbol representing an arithmetic calculation or process.