Re: min/max routines [message #7403] |
Wed, 13 November 1996 00:00 |
meron
Messages: 51 Registered: July 1995
|
Member |
|
|
In article <328A0DE2.11F@lanl.gov>, Dot Delapp <ddelapp@lanl.gov> writes:
> Is there a routine similar to the fortran and c min max functions
> that returns the max or min of two numbers?
>
You don't need a routine. Given two numbers, a and b, the statement
c = a > b
gives the max of the two, while
c = a < b
gives the min.
Mati Meron | "When you argue with a fool,
meron@cars.uchicago.edu | chances are he is doing just the same"
|
|
|
Re: min/max routines [message #7405 is a reply to message #7403] |
Wed, 13 November 1996 00:00  |
Andy Loughe
Messages: 174 Registered: November 1995
|
Senior Member |
|
|
Dot Delapp wrote:
>
> Is there a routine similar to the fortran and c min max functions
> that returns the max or min of two numbers?
>
> Thanks
Sure!
IDL> a = 40
IDL> b = 45
IDL> print, min([a,b]), max([a,b])
40 45
--
Andrew F. Loughe afl@cdc.noaa.gov
University of Colorado, CIRES http://cdc.noaa.gov/~afl
Campus Box 449 phn:(303)492-0707 fax:(303)497-7013
Boulder, CO 80309-0449 "He who laughs last thinks slowest!"
|
|
|
Re: min/max routines [message #7406 is a reply to message #7403] |
Wed, 13 November 1996 00:00  |
Tim Patterson
Messages: 65 Registered: October 1995
|
Member |
|
|
Dot Delapp wrote:
>
> Is there a routine similar to the fortran and c min max functions
> that returns the max or min of two numbers?
>
> Thanks
For two or more separate numbers, you can use < and > for min/max
Examples:
> print, 1< 2
1
> print, 22 < 1.5 < 3 < 6 < 7
1.5
> temp = 1 > 3 > 2
> print, temp
3
There's more under "Miminum Operator" and "Maximum Operator"
in the IDL manuals.
Hope this helps
Tim
|
|
|