Hide minor edits - Show changes to markup

June 01, 2010, at 01:54 AM
by

- Changed lines 1-10 from:

These operators return the sum, difference, product, or quotient (respectively) of the two operands. The operation is conducted using the data type of the operands, so, for example, `9 / 4`

gives `2`

since 9 and 4 are ints. This also means that the operation can overflow if the result is larger than that which can be stored in the data type (e.g. adding 1 to an int with the value 32,767 gives -32,768). If the operands are of different types, the "larger" type is used for the calculation.

If one of the numbers (operands) are of the type **float** or of type **double**, floating point math will be used for the calculation.

to:

Estos operadores devuelven la suma, diferencia, producto o cociente (respectivamente) de los dos operandos. La operación se lleva a cabo utilizando el tipo de datos de los operandos, por lo que, por ejemplo, `9 / 4`

resulta `2`

desde 9 y 4 que son enteros int. Esto también significa que la operación puede desbordarse si el resultado es mayor que el que se puede almacenar en el tipo de datos (por ejemplo, la suma de 1 a un int con el valor de 32.767 resulta -32.768). Si los operandos son de tipos diferentes, se utiliza el tipo del "más grande" para el cálculo.

Si uno de los números (operandos) es del tipo **float** o del tipo **double**, se usará coma flotante para el cálculo.

Changed lines 17-18 from:

to:

Changed lines 26-48 from:

value1: any variable or constant

value2: any variable or constant

- Know that integer constants default to int, so some constant calculations may overflow (e.g. 60 * 1000 will yield a negative result).
- Choose variable sizes that are large enough to hold the largest results from your calculations
- Know at what point your variable will "roll over" and also what happens in the other direction e.g. (0 - 1) OR (0 - - 32768)
- For math that requires fractions, use float variables, but be aware of their drawbacks: large size, slow computation speeds
- Use the cast operator e.g. (int)myFloat to convert one variable type to another on the fly.

to:

value1: cualquier variable o constante

value2: cualquier variable o constante

- Debes saber que las integer constants por defecto son int, así que algunos cálculos con constantes pueden provocar desbordamiento (p.e. 60 * 1000 devolverá un resultado negativo)
- Elige los tamaños de variable que sean suficientemente grandes como para alojar el resultado de tus calculos.
- Debes saber en que punto tu variable se desbordará en su máximo, y que esto también ocurre en su mínimo. p.e. (0 - 1) o también (0 - - 32768)
- Para cálculos matemáticos que requieren fracciones, usa variables float, pero ten en cuenta los inconvenientes: gran tamaño, velocidades bajas de cálculo
- Usa el operador de conversión (casting). Por ejemplo: (int)myFloat para convertir el tipo de una variable en el momento.

February 13, 2008, at 05:43 PM
by

- Changed lines 5-6 from:

These operators return the sum, difference, product, or quotient (respectively) of the two operands. The operation is conducted using the data type of the operands, so, for example, `9 / 4`

gives `2`

since 9 and 4 are ints. This also means that the operation can overflow if the result is larger than that which can be stored in the data type. If the operands are of different types, the "larger" type is used for the calculation.

to:

These operators return the sum, difference, product, or quotient (respectively) of the two operands. The operation is conducted using the data type of the operands, so, for example, `9 / 4`

gives `2`

since 9 and 4 are ints. This also means that the operation can overflow if the result is larger than that which can be stored in the data type (e.g. adding 1 to an int with the value 32,767 gives -32,768). If the operands are of different types, the "larger" type is used for the calculation.

Added lines 35-36:

- Know that integer constants default to int, so some constant calculations may overflow (e.g. 60 * 1000 will yield a negative result).

May 29, 2007, at 03:24 AM
by

- May 29, 2007, at 03:23 AM
by

- Changed line 7 from:

If one of the numbers (operands) are of the type **float** or of type **double**, floating point math will be used for the operation.

to:

If one of the numbers (operands) are of the type **float** or of type **double**, floating point math will be used for the calculation.

May 29, 2007, at 03:21 AM
by

- Changed lines 5-6 from:

These operators return the sum, difference, product, or quotient (respectively) of the two operands. The operation is conducted using the data type of the operands, so, for example, `9 / 4`

gives `2`

since 9 and 4 are ints. This also means that the operation can overflow if the result is larger than that which can be stored in the data type. If the operands are of different types, the "larger" type is used for the calculation.

to:

These operators return the sum, difference, product, or quotient (respectively) of the two operands. The operation is conducted using the data type of the operands, so, for example, `9 / 4`

gives `2`

since 9 and 4 are ints. This also means that the operation can overflow if the result is larger than that which can be stored in the data type. If the operands are of different types, the "larger" type is used for the calculation.

If one of the numbers (operands) are of the type **float** or of type **double**, floating point math will be used for the operation.

Changed lines 33-34 from:

to:

Changed lines 41-47 from:

- Use the cast operator e.g. (int)myfloat to convert one variable type to another on the fly.

to:

- Use the cast operator e.g. (int)myFloat to convert one variable type to another on the fly.

April 16, 2007, at 05:18 AM
by

- Changed lines 38-41 from:

- Use the cast operator eg (int)myfloat to convert one variable type to another on the fly.

to:

- Use the cast operator e.g. (int)myfloat to convert one variable type to another on the fly.

April 16, 2007, at 05:11 AM
by

- Changed lines 5-6 from:

The arithmetic operators work exactly as one expects with the result returned being the result of the two values and the operator

to:

`9 / 4`

gives `2`

since 9 and 4 are ints. This also means that the operation can overflow if the result is larger than that which can be stored in the data type. If the operands are of different types, the "larger" type is used for the calculation.

Changed lines 17-18 from:

result = value1 [+-*/] value2

to:

result = value1 + value2; result = value1 - value2; result = value1 * value2; result = value1 / value2;

Changed lines 26-28 from:

value1: any variable type

value2: any variable type

to:

value1: any variable or constant

value2: any variable or constant

April 15, 2007, at 11:11 PM
by

- Changed lines 26-29 from:

A longer tutorial on computer math can eventually go in this space but for now, to benefit beginning programmers some general guidelines will be presented. These will hopefully get you started toward getting the same answer out of your Arduino that you do on your calculator.

- Choose variable sizes that you are sure are large enough to hold the largest results from your calculations

to:

- Choose variable sizes that are large enough to hold the largest results from your calculations

Changed lines 32-34 from:

to:

- Use the cast operator eg (int)myfloat to convert one variable type to another on the fly.

April 15, 2007, at 11:08 PM
by

- Changed lines 28-30 from:

to:

- Choose variable sizes that you are sure are large enough to hold the largest results from your calculations
- Know at what point your variable will "roll over" and also what happens in the other direction e.g. (0 - 1) OR (0 - - 32768)
- For math that requires fractions, use float variables, but be aware of their drawbacks: large size, slow computation speeds

April 15, 2007, at 11:03 PM
by

- Changed line 21 from:

value1: any variable type

to:

value1: any variable type\\\

Changed lines 26-32 from:

For beginning programmers there are several details of doing math on the computer to which one must pay attention. One is that math on computers, as opposed to algebra class, must exist in physical space. This means that the variable (which occupies a physical space on your Atmega chip) must be large enough to hold the results of your calculations.

Hence if you try something like this

byte x; x = 255; x = x + 1;

to:

A longer tutorial on computer math can eventually go in this space but for now, to benefit beginning programmers some general guidelines will be presented. These will hopefully get you started toward getting the same answer out of your Arduino that you do on your calculator.

April 15, 2007, at 10:59 PM
by

- Added lines 14-18:

result = value1 [+-*/] value2

April 15, 2007, at 10:27 PM
by

- Changed line 8 from:

to:

[@

Changed line 13 from:

to:

@]

Changed lines 26-27 from:

x = x + 1;

to:

x = x + 1; @]

April 15, 2007, at 10:23 PM
by

- Added lines 1-27:

The arithmetic operators work exactly as one expects with the result returned being the result of the two values and the operator

y = y + 3; x = x - 7; i = j * 6; r = r / 5;

value1: any variable type value2: any variable type

For beginning programmers there are several details of doing math on the computer to which one must pay attention. One is that math on computers, as opposed to algebra class, must exist in physical space. This means that the variable (which occupies a physical space on your Atmega chip) must be large enough to hold the results of your calculations.

Hence if you try something like this [@ byte x; x = 255; x = x + 1;