Ediojde3W

Páginas: 16 (3804 palabras) Publicado: 20 de noviembre de 2012
Expressions
===========
M.U.G.E.N, (c) Elecbyte 2002
Documentation for version 2002.04.14

Beta-release documentation
Updated 27 October 2001



====================================================================
0. Contents
====================================================================

MUGEN supports the use of arithmetic expressions in the CNS and CMD files. This documentgives a complete description of
expression syntax.

I. Data types: Ints and Floats
II. Arithmetic operators
III. Precedence and associativity of operators
IV. Expression syntax
V. Triggers
VI. Trigger redirection
VII. SC values
VIII. More on function-type triggers
IX. Expressions in state and state controller parameters
X. (Advanced) Optimizing for speed====================================================================
I. Data types: Ints and Floats
====================================================================

An int is a whole number, such as 0, 1, -4, etc. Ints can assume values
between about -2 billion and 2 billion. A float is a real number which
has a "decimal part", such as 5.24, or -4247.44. Note that a whole number such as 55can also be represented as a float, thus: 55.0. Floats offer only 7 significant figures of precision.

The behavior of arithmetic expressions depends heavily on the underlying data types used to represent numbers. Also, state controllers may expect their input to be given as a certain type, and will give errors if the wrong type is supplied.====================================================================
II. Arithmetic operators
====================================================================

In addition to the familiar arithmetic operators like +, -, *, and /,
several other operators exist which act on their input values in
different ways. This section describes the behavior of these operators.

+
The familiar addition operator. x + y evaluates to an int if xand y
are both ints, or a float if x and y are both floats. If one of x or y
is a float, then both are converted to floats (with possible loss
of precision in the process) and then x + y is evaluated as a sum
of floats.

-
The familiar subtraction operator. As with addition, x - y evaluates
to an int if x and y are both ints, or a float if they are both floats.
If one of x or y is afloat, they are both converted to floats and the
subtraction is performed as a subtraction of floats.

-
If - appears in a context where the subtraction operator is not
appropriate, it is interpreted as the negation operator. That is, given input x, "-x" represents the value -x. Returns the same type as x's.

*
The multiplication operator. The behavior is similar to the + and -operators.

/
The division operator. If x and y are both ints, then x/y gives the
number of times that y goes evenly into x. For instance, 7/2 = 3,
because 2 goes into 7 three times (with a remainder of 1 which is
discarded). If x and y are both floats, then x/y returns a float. For
instance, 7.0/2.0 = 3.5. Finally, if one of x or y is a float, they are both converted to floats beforeevaluation.
The result of a division by zero will be discussed in the section on
SC values.

%
The remainder or mod operator. If x and y are both ints, x%y returns
an int representing the remainder after performing a division x/y. For
instance, 7%2 = 1, and 23 % 17 = 6. It is an error to use the % operator on float values, or to compute x%0. The result of such operations will be discussed in thesection on SC values.

**
The exponentiation operator. If x and y are both ints >= 0, then x**y
gives an int representing x raised to the power of y (we define 0**0 =
1). Otherwise, x**y is computed as an exponentiation of real numbers
(converting x and y to floats first if necessary). The result of an
invalid exponentiation such as -1^.5 will be discussed in the section on SC values....
Leer documento completo

Regístrate para leer el documento completo.

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS