mozilla
Los resultados de tu búsqueda

    Aritméticos

    This translation is incomplete. Please help translate this article from English.

    Sumario

    Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value. The standard arithmetic operators are addition (+), subtraction (-), multiplication (*), and division (/).

    These operators work as they do in most other programming languages, except the / operator returns a floating-point division in JavaScript, not a truncated division as it does in languages such as C or Java. Por ejemplo:

    1/2 //devuelve 0.5 en JavaScript
    1/2 //devuelve 0 en Java 
    

    % (modular)

    The modulus operator is used as follows:

    var1  % var2

    The modulus operator returns the first operand modulo the second operand, that is, var1 modulo var2, in the preceding statement, where var1 and var2 are variables. The modulo function is the integer remainder of dividing var1 by var2. For example, 12 % 5 returns 2.

    ++ (incremento)

    El operador de incremento es usado como sigue:

    var ++ or ++ var

    This operator increments (adds one to) its operand and returns a value. If used postfix, with operator after operand (for example, x++), then it returns the value before incrementing. If used prefix with operator before operand (for example, ++x), then it returns the value after incrementing.

    For example, if x is three, then the statement y = x++ sets y to 3 and increments x to 4. If x is 3, then the statement y = ++x increments x to 4 and sets y to 4.

    -- (decremento)

    El operador de decremento es usado como sigue:

    var -- or -- var

    This operator decrements (subtracts one from) its operand and returns a value. If used postfix (for example, x--), then it returns the value before decrementing. If used prefix (for example, --x), then it returns the value after decrementing.

    Por ejemplo, if x is three, then the statement y = x-- sets y to 3 and decrements x to 2. If x is 3, then the statement y = --x decrements x to 2 and sets y to 2.

    - (negación unitario)

    The unary negation operator precedes its operand and negates it.

    Por ejemplo, y = -x negates the value of x and assigns that to y; that is, if x were 3, y would get the value -3 and x would retain the value 3.

    Etiquetas y colaboradores del documento

    Etiquetas: 
    Contributors to this page: teoli, Mgjbot, Nathymig, SphinxKnight
    Última actualización por: SphinxKnight,
    Ocultar la barra lateral