Make a number equal to the bigger number

Discussion in 'Microsoft Dot NET' started by chriswo2k@gmail.com, Aug 22, 2012.

  1. Guest

    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
     
    , Aug 22, 2012
    #1
    1. Advertisements

  2. ozbear Guest

    On Wed, 22 Aug 2012 06:53:55 -0700 (PDT), 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?
     
    ozbear, Aug 26, 2012
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William Ryan

    Who's a bigger Troll, Bailo or NoSpam?

    William Ryan, Nov 8, 2003, in forum: Microsoft Dot NET
    Replies:
    6
    Views:
    213
    Michael Giagnocavo [MVP]
    Nov 11, 2003
  2. Murt

    'less than or equal to' signs

    Murt, Nov 10, 2003, in forum: Microsoft Dot NET
    Replies:
    8
    Views:
    193
    Armin Zingler
    Nov 11, 2003
  3. Lloyd Sheen

    A date is not equal to a date????

    Lloyd Sheen, Jan 26, 2004, in forum: Microsoft Dot NET
    Replies:
    1
    Views:
    159
  4. Ayende Rahien

    When "ToString" does not equal "ToString"

    Ayende Rahien, Oct 7, 2004, in forum: Microsoft Dot NET
    Replies:
    7
    Views:
    213
    Pradeep
    Oct 8, 2004
  5. Guest

    Why does hte file size get bigger?

    Guest, Feb 5, 2007, in forum: Microsoft Dot NET
    Replies:
    1
    Views:
    273
    RobinS
    Feb 5, 2007
Loading...

Share This Page