From: G [mailto:[EMAIL PROTECTED]
Got three variables passed into me, all are decimal values.
What is the quickest and most elegant way of determining
which of the variables holds the largest value?
Max(Max(number1, number2),number3)
Mike
ty MT.
From: G [mailto:[EMAIL PROTECTED]
Got three variables passed into me, all are decimal values.
What is the quickest and most elegant way of determining
which of the variables holds the largest value?
Max(Max(number1, number2),number3)
Mike
Max() should do it if you're not going to eventually have more values.
Think it can only take 2 values so nest them like max(max(no1, no2), no3)
If its going to be more... just loop them, if the currnent value is larger
than the previous, set it to the max...
cfset max = 0
cfloop
For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))
-Calvin
-Original Message-
From: Ewok [mailto:[EMAIL PROTECTED]
Sent: Friday, April 15, 2005 9:10 AM
To: CF-Talk
Subject: RE: Max value of 3 variables
Max() should do it if you're not going to eventually have more
Or #arrayMax(listToArray(numbers))#
-Original Message-
From: Calvin Ward [mailto:[EMAIL PROTECTED]
Sent: Friday, April 15, 2005 7:18 AM
To: CF-Talk
Subject: RE: Max value of 3 variables
For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))
-Calvin
-Original
the maximum value first in the
list?
Rick
-Original Message-
From: Paul [mailto:[EMAIL PROTECTED]
Sent: Friday, April 15, 2005 10:44 AM
To: CF-Talk
Subject: RE: Max value of 3 variables
Or #arrayMax(listToArray(numbers))#
-Original Message-
From: Calvin Ward [mailto:[EMAIL
It should, but you'll probably actually have to add the desc attribute at
the end of my suggestion.
- Calvin
-Original Message-
From: Rick Faircloth [mailto:[EMAIL PROTECTED]
Sent: Friday, April 15, 2005 11:08 AM
To: CF-Talk
Subject: RE: Max value of 3 variables
Or #arrayMax
Calvin Ward wrote:
For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))
If we were talking about a lower-level language, I'd warn against that
way of doing it. On average, ListSort() takes O(nlogn) to sort a list,
whereas scanning the list with cfloop as below will be done in
ListFirst(ListSort(numbers,'numeric'))
It should, but you'll probably actually have to add the
desc attribute at the end of my suggestion.
Or use listLast() instead.
-Justin
~|
Logware (www.logware.us): a new and
Rick Faircloth wrote:
Or #arrayMax(listToArray(numbers))#
For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))
And how, exactly, would these assist in obtaining
the top value of 3 numbers?
Does arrayMax put the maximum value first in the array?
No, it searches the
arrayMax returns the largest numeric value in an array.
http://livedocs.macromedia.com/coldfusion/7/htmldocs/0388.htm
-Original Message-
From: Rick Faircloth [mailto:[EMAIL PROTECTED]
Sent: Friday, April 15, 2005 9:08 AM
To: CF-Talk
Subject: RE: Max value of 3 variables
Gotcha...thanks...
Rick
-Original Message-
From: Keith Gaughan [mailto:[EMAIL PROTECTED]
Sent: Friday, April 15, 2005 11:36 AM
To: CF-Talk
Subject: Re: Max value of 3 variables
Rick Faircloth wrote:
Or #arrayMax(listToArray(numbers))#
For flexibility, how about
12 matches
Mail list logo