PC Review


Reply
Thread Tools Rate Thread

Make a number equal to the bigger number

 
 
chriswo2k@gmail.com
Guest
Posts: n/a
 
      22nd Aug 2012
hello

whats the best way to make a number equal to a bigger number?

so say we have:

int one = 1;
int two = 2;
int three = 3;
int biggest;

is there a way to set biggest to whatever number (one, two, three) is biggest?

all I can come up with is a loooong if-else sequence. gotta be a way to do this in a line or two.

ChrisW
 
Reply With Quote
 
 
 
 
ozbear
Guest
Posts: n/a
 
      26th Aug 2012
On Wed, 22 Aug 2012 06:53:55 -0700 (PDT), (E-Mail Removed) wrote:

>hello
>
>whats the best way to make a number equal to a bigger number?
>
>so say we have:
>
>int one = 1;
>int two = 2;
>int three = 3;
>int biggest;
>
>is there a way to set biggest to whatever number (one, two, three) is biggest?
>
>all I can come up with is a loooong if-else sequence. gotta be a way to do this in a line or two.
>
>ChrisW


biggest = one > two && one > three ? one : two > three ? two : three;

In other words, if the first conditional clause is true, then "one"
must be the biggest. Otherwise either either "two" or "three" or both
are bigger than "one" so the problem reduces to finding the larger of
"two" and "three" which the second conditional determines.

Oz
--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2000 (9.0.6926 SP3) spreadsheet getting bigger & bigger .... =?Utf-8?B?TGVhdGg=?= Microsoft Excel Misc 2 14th Mar 2006 07:04 AM
records size growing bigger and bigger =?Utf-8?B?U2ltb24gV29uZw==?= Microsoft Access 1 3rd Mar 2006 02:01 PM
How do I manage archive file since it is bigger and bigger? =?Utf-8?B?WW9zaGk=?= Microsoft Outlook Installation 1 16th Sep 2005 10:02 PM
Workbook Bigger and Bigger =?Utf-8?B?WWUgWWludCBXaW4=?= Microsoft Excel Programming 1 21st Jun 2005 01:38 PM
Buttons in OE toolbar are getting bigger and bigger =?Utf-8?B?TWF0dA==?= Windows XP Help 1 13th Nov 2004 04:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:48 PM.