Reference.Max History

Hide minor edits - Show changes to markup

June 03, 2010, at 07:04 AM by Equipo Traduccion -
Changed lines 31-32 from:

max(a, 0); // mantener las operaciones fuera de la función.

to:

max(a, 0); // mantener cualquier operación fuera de los paréntesis.

June 02, 2010, at 02:38 AM by Equipo Traduccion -
Changed lines 25-26 from:

Debido a la forma en que la función max()es implementada, debes evitar usar otras funciones al definir los parámetros, puede derivar en resultados incorrectos.

to:

Debido a la forma en que la función max() es implementada, debes evitar usar otras funciones al definir los parámetros, puede derivar en resultados incorrectos.

June 02, 2010, at 02:37 AM by Equipo Traduccion -
Changed lines 3-25 from:

Description

Calculates the maximum of two numbers.

Parameters

x: the first number, any data type

y: the second number, any data type

Returns

The larger of the two parameter values.

Example

sensVal = max(senVal, 20); // assigns sensVal to the larger of sensVal or 20
                           // (effectively ensuring that it is at least 20)

Note

Perhaps counter-intuitively, max() is often used to constrain the lower end of a variable's range, while min() is used to constrain the upper end of the range.

Warning

Because of the way the max() function is implemented, avoid using other functions inside the brackets, it may lead to incorrect results

to:

Descripción

Calcula el máximo de dos números.

Parámetros

x: El primer número, cualquier tipo de dato.

y: El segundo número, cualquier tipo de dato.

Devuelve

El mayor de ambos parámetros.

Ejemplo

sensVal = max(senVal, 20); // asigna a sensVal su propio valor o, de ser superior, 20.
                           // (una forma efectiva de asegurarse que el valor mínimo de senVal sea 20)

Nota

max() suele ser usado para restringir el valor más bajo del rango de una variable, mientras que min() es utilizado para restringir el valor máximo del rango.

Atención

Debido a la forma en que la función max()es implementada, debes evitar usar otras funciones al definir los parámetros, puede derivar en resultados incorrectos.

Changed lines 28-31 from:

max(a--, 0); // avoid this - yields incorrect results

a--; // use this instead - max(a, 0); // keep other math outside the function

to:

max(a--, 0); // evitar esto - puede dar resultados incorrectos.

a--; // en su lugar, hacerlo así - max(a, 0); // mantener las operaciones fuera de la función.

Changed lines 35-36 from:

See also

to:

Ver También

Changed lines 39-40 from:
to:

February 06, 2010, at 09:26 AM by David A. Mellis -
Changed lines 38-40 from:
to:
February 06, 2010, at 02:48 AM by Paul Badger -
Changed lines 38-39 from:
to:
January 27, 2009, at 12:53 PM by Paul Badger -
Changed line 30 from:

max(a, 0); // keep other math outside the function

to:

max(a, 0); // keep other math outside the function

January 27, 2009, at 12:25 PM by David A. Mellis -
Changed line 30 from:

min(a, 100); // keep other math outside the function

to:

max(a, 0); // keep other math outside the function

January 27, 2009, at 06:53 AM by Paul Badger -
January 27, 2009, at 06:52 AM by Paul Badger -
Changed lines 23-33 from:
to:

Warning

Because of the way the max() function is implemented, avoid using other functions inside the brackets, it may lead to incorrect results

max(a--, 0);   // avoid this - yields incorrect results

a--;           // use this instead -
min(a, 100);   // keep other math outside the function

November 04, 2007, at 05:30 AM by Paul Badger -
Changed lines 19-21 from:
                           // (effectively ensuring that it is at least 20)

@]

to:
                           // (effectively ensuring that it is at least 20)@]
November 04, 2007, at 05:30 AM by Paul Badger -
Added lines 22-25:

Note

Perhaps counter-intuitively, max() is often used to constrain the lower end of a variable's range, while min() is used to constrain the upper end of the range.

November 04, 2007, at 05:24 AM by Paul Badger -
Changed lines 15-16 from:

The larger of the two numbers.

to:

The larger of the two parameter values.

November 04, 2007, at 05:24 AM by Paul Badger -
Changed line 18 from:

[@sensVal = max(senVal, 20); // assigns sensVal to the bigger of sensVal or 20

to:

[@sensVal = max(senVal, 20); // assigns sensVal to the larger of sensVal or 20

November 04, 2007, at 05:23 AM by Paul Badger -
Changed line 19 from:
                             // (effectively ensuring that it is at least 20)
to:
                           // (effectively ensuring that it is at least 20)
November 04, 2007, at 05:23 AM by Paul Badger -
Changed lines 18-19 from:

[@sensVal = max(senVal, 20); // assigns sensVal to the bigger of sensVal or 20 (effectively ensuring that it is at least 20)

to:

[@sensVal = max(senVal, 20); // assigns sensVal to the bigger of sensVal or 20

                             // (effectively ensuring that it is at least 20)
April 16, 2007, at 06:05 PM by Paul Badger -
Changed line 26 from:
to:
April 16, 2007, at 09:12 AM by David A. Mellis -
Changed line 18 from:

[@sensVal = max(senVal, 20); // limits sensor value to at least 20

to:

[@sensVal = max(senVal, 20); // assigns sensVal to the bigger of sensVal or 20 (effectively ensuring that it is at least 20)

Deleted lines 20-24:

Tips

max is useful for limiting the range a variable (say reading a sensor) can move. Even though the name max would seem to suggest it should be used to limit the sensor's maximum value, its real effect is to limit the variable's lowest value. This can be slightly counterintuitive.

Programmers coming to C from the BASIC language may also expect max to affect a variable without assigning the returned result to anything.

April 15, 2007, at 03:49 AM by Paul Badger -
Changed lines 17-18 from:

Examples

[@sensVal = max(senVal, 20); // limits sensor value to 20 MINIMUM

to:

Example

[@sensVal = max(senVal, 20); // limits sensor value to at least 20

Changed lines 21-26 from:

Common Programming Errors

Paradoxically, even though max would seem to limit the desired variable to a maximum value, it is really used to set the minimum value to which a variable can descend.

Programmers coming to C from the BASIC language may expect max to affect a variable without assigning the returned result to anything

to:

Tips

max is useful for limiting the range a variable (say reading a sensor) can move. Even though the name max would seem to suggest it should be used to limit the sensor's maximum value, its real effect is to limit the variable's lowest value. This can be slightly counterintuitive.

Programmers coming to C from the BASIC language may also expect max to affect a variable without assigning the returned result to anything.

April 14, 2007, at 06:11 AM by Paul Badger -
Changed lines 9-12 from:

x: the first number

y: the second number

to:

x: the first number, any data type

y: the second number, any data type

Changed lines 15-16 from:

The bigger of the two numbers.

to:

The larger of the two numbers.

Examples

sensVal = max(senVal, 20); // limits sensor value to 20 MINIMUM

Common Programming Errors

Paradoxically, even though max would seem to limit the desired variable to a maximum value, it is really used to set the minimum value to which a variable can descend.

Programmers coming to C from the BASIC language may expect max to affect a variable without assigning the returned result to anything

December 02, 2006, at 07:00 PM by David A. Mellis -
Changed lines 20-22 from:
to:
December 02, 2006, at 06:10 PM by David A. Mellis -
Added lines 1-20:

max(x, y)

Description

Calculates the maximum of two numbers.

Parameters

x: the first number

y: the second number

Returns

The bigger of the two numbers.

See also

Share