# 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

ozbear
Guest
Posts: n/a

 26th Aug 2012
On Wed, 22 Aug 2012 06:53:55 -0700 (PDT), http://www.pcreview.co.uk/forums/(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?

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post =?Utf-8?B?TGVhdGg=?= Microsoft Excel Misc 2 14th Mar 2006 07:04 AM =?Utf-8?B?U2ltb24gV29uZw==?= Microsoft Access 1 3rd Mar 2006 02:01 PM =?Utf-8?B?WW9zaGk=?= Microsoft Outlook Installation 1 16th Sep 2005 10:02 PM =?Utf-8?B?WWUgWWludCBXaW4=?= Microsoft Excel Programming 1 21st Jun 2005 01:38 PM =?Utf-8?B?TWF0dA==?= Windows XP Help 1 13th Nov 2004 04:06 PM

Features