Reference.Min History

Hide minor edits - Show changes to output

February 06, 2010, at 09:26 AM by David A. Mellis -
Changed lines 40-42 from:
* [[Mathh|math.h]]

to:

February 06, 2010, at 02:47 AM by Paul Badger -
Changed lines 40-41 from:

to:
* [[Mathh|math.h]]

January 27, 2009, at 06:50 AM by Paul Badger -
Changed lines 28-29 from:
min(a++, 100); // avoid this - counts by two's
to:
min(a++, 100); // avoid this - yields incorrect results
January 27, 2009, at 06:49 AM by Paul Badger -
Changed lines 32-34 from:


to:
@]


January 27, 2009, at 06:49 AM by Paul Badger -
Added lines 23-34:

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

[@
min(a++, 100); // avoid this - counts by two's

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


November 04, 2007, at 05:32 AM by Paul Badger -
Changed lines 19-20 from:
// ensuring that it never gets above 100.
@]
to:
// ensuring that it never gets above 100.@]
November 04, 2007, at 05:32 AM by Paul Badger -
Deleted line 20:
November 04, 2007, at 05:32 AM by Paul Badger -
Changed lines 18-19 from:
[@sensVal = min(sensVal, 100); // assigns sensVal to the smaller of sensVal or 100, ensuring that it never gets above 100.
to:
[@sensVal = min(sensVal, 100); // assigns sensVal to the smaller of sensVal or 100
// ensuring that it never gets above 100.
Added lines 22-24:
!!!!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.
April 16, 2007, at 06:06 PM by Paul Badger -
Changed line 26 from:
[[HomePage | Reference Home]]
to:
April 16, 2007, at 09:13 AM by David A. Mellis -
Changed line 18 from:
[@sensVal = min(senVal, 100); // limits sensor's top reading to 100 maximum
to:
[@sensVal = min(sensVal, 100); // assigns sensVal to the smaller of sensVal or 100, ensuring that it never gets above 100.
Deleted lines 20-24:
!!!!Tip
min is useful for limiting the range a variable (say reading a sensor) can move. Even though the name min would seem to suggest it should be used to limit the sensor's minimum value, its real effect is to limit the variable's highest value. This can be slightly counterintuitive.

Programmers coming to C from the BASIC language may alsoexpect min to affect a variable without assigning the returned result to anything.
April 15, 2007, at 03:43 AM by Paul Badger -
Changed line 18 from:
[@sensVal = min(senVal, 100); // limits sensor to 100 MAXIMUM
to:
[@sensVal = min(senVal, 100); // limits sensor's top reading to 100 maximum
Changed lines 21-25 from:
!!!!Common Programming Errors
Paradoxically, even though min would seem to limit the desired variable to a minimum value, it is really used to set the maximum value a variable can hold.

Programmers coming to C from the BASIC language may expect min to affect a variable without assigning the returned result to anything
to:
!!!!Tip
min is useful for limiting the range a variable (say reading a sensor) can move. Even though the name min would seem to suggest it should be used to limit the sensor's minimum value, its real effect is to limit the variable's highest value. This can be slightly counterintuitive.

Programmers coming to C from the BASIC language may alsoexpect min to affect a variable without assigning the returned result to anything.
April 14, 2007, at 07:55 AM by Paul Badger -
Changed lines 22-23 from:
Paradoxically, even though min would seem to limit the desired variable to a minimum value, it is really used to set the maximum value a variable can achieve.
to:
Paradoxically, even though min would seem to limit the desired variable to a minimum value, it is really used to set the maximum value a variable can hold.
April 14, 2007, at 07:54 AM by Paul Badger -
Changed line 18 from:
[@sensVal = min(senVal, 100); // limits sensor to 100 MAX
to:
[@sensVal = min(senVal, 100); // limits sensor to 100 MAXIMUM
April 14, 2007, at 06:13 AM by Paul Badger -
April 14, 2007, at 06:06 AM by Paul Badger -
April 14, 2007, at 06:05 AM by Paul Badger -
Changed line 18 from:
[@sensVal = min(senVal, 100); // limits sensor to 100 max
to:
[@sensVal = min(senVal, 100); // limits sensor to 100 MAX
April 14, 2007, at 06:04 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
Added lines 17-25:
!!!!Examples
[@sensVal = min(senVal, 100); // limits sensor to 100 max
@]

!!!!Common Programming Errors
Paradoxically, even though min would seem to limit the desired variable to a minimum value, it is really used to set the maximum value a variable can achieve.

Programmers coming to C from the BASIC language may expect min to affect a variable without assigning the returned result to anything
December 02, 2006, at 06:59 PM by David A. Mellis -
Changed lines 20-22 from:
* [[constrain]]()
to:
* [[constrain]]()

[[HomePage | Reference Home]]
December 02, 2006, at 06:10 PM by David A. Mellis -
Added lines 1-20:
!!min(x, y)

!!!!Description

Calculates the minimum of two numbers.

!!!!Parameters

x: the first number

y: the second number

!!!!Returns

The smaller of the two numbers.

!!!!See also

* [[max]]()
* [[constrain]]()

Share