473,385 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Getting Maximum value of 6 numbers

Here is how I've done it.

intMAX = Math.Max(Math.Max(Math.Max(dr("NAQty"),
dr("CurrentNotRequiredYetQty")), Math.Max(dr("OutstandingQty"),
dr("SavedQty"))), Math.Max(dr("UnapprovedQty"), dr("UpdatedQty")))

Is there a better way?
Nov 19 '05 #1
3 1274
John Yatla wrote:
Here is how I've done it.

intMAX = Math.Max(Math.Max(Math.Max(dr("NAQty"),
dr("CurrentNotRequiredYetQty")), Math.Max(dr("OutstandingQty"),
dr("SavedQty"))), Math.Max(dr("UnapprovedQty"), dr("UpdatedQty")))

Is there a better way?

I am not sure of performance metrics, but you could just put the numbers
into an array, and then use the Array.Sort method.

The highest number will then be in the LAST index position of the array
(index 5 for a 6 item array);

HTH...

Chris
Nov 19 '05 #2
Alternatively, since you are obviously pulling these numbers from a
database, you could do the sort in the database.

The array method would probably work best though.

Lowell

Chris Hyde wrote:
John Yatla wrote:
Here is how I've done it.

intMAX = Math.Max(Math.Max(Math.Max(dr("NAQty"),
dr("CurrentNotRequiredYetQty")), Math.Max(dr("OutstandingQty"),
dr("SavedQty"))), Math.Max(dr("UnapprovedQty"), dr("UpdatedQty")))

Is there a better way?

I am not sure of performance metrics, but you could just put the numbers
into an array, and then use the Array.Sort method.

The highest number will then be in the LAST index position of the array
(index 5 for a 6 item array);

HTH...

Chris

Nov 19 '05 #3
I think the way you are using will be faster if comparing with the Array
techniques, but obviously the code looks untidy. :)

weichung
"Chris Hyde" <ch*****@nodirecwayspam.com> wrote in message
news:u7**************@TK2MSFTNGP12.phx.gbl...
John Yatla wrote:
Here is how I've done it.

intMAX = Math.Max(Math.Max(Math.Max(dr("NAQty"),
dr("CurrentNotRequiredYetQty")), Math.Max(dr("OutstandingQty"),
dr("SavedQty"))), Math.Max(dr("UnapprovedQty"), dr("UpdatedQty")))

Is there a better way?

I am not sure of performance metrics, but you could just put the numbers
into an array, and then use the Array.Sort method.

The highest number will then be in the LAST index position of the array
(index 5 for a 6 item array);

HTH...

Chris

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: KemperR | last post by:
Dear All, may be some of you can help me with an XSLT example how to solve the following challange. For the XML below I want to find out the maximum hierarchy level for a specific element in my...
2
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
2
by: MrNobody | last post by:
I have been struggling with .NET's scrollbars because when I use them I can't seem to get them to go to their maximum value. Searching on the web it looks like the maximum Value you can get on...
29
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
2
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function...
6
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm using the VScrollBar and set it as follow: m_vScrollBar.Minimum = -19602; m_vScrollBar.Maximum = 0; m_vScrollBar.SmallChange = 1; m_vScrollBar.LargeChange = 1089; m_vScrollBar.Value =...
11
by: zj262144 | last post by:
Hi, I'm a C beginner. I want to write a C. The pseudocodes are like this: User enters some numbers (use -1 to end) The compiler find and delete the maximum and minimum numbers Then average...
1
AaronL
by: AaronL | last post by:
Hello, First I would like to say thank you all for your help in the past. I am stumped again. I am creating an e-commerce system and I want to be able to upload images to the server and...
9
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.