A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: comparitive operation a/s question

  1. #1
    Senior Member charlie_says's Avatar
    Join Date
    Feb 2003
    Location
    UK
    Posts
    508

    comparitive operation a/s question

    I know this can be done with if(), but is there not an operation which can do this.
    I am checking between 2 variables and whichever is smallest is assigned to a third.
    if (a<=b) {
    c = a
    } else if (b<a) {
    c = b
    }

  2. #2
    Senior Member
    Join Date
    Jun 2002
    Location
    Manchester, UK
    Posts
    2,357
    That should work!!!
    Code:
    a = 5;
    b = 7;
    c = (a<=b) ? a : b;
    trace(c);

  3. #3
    Elvis...who tha f**k is Elvis? phreax's Avatar
    Join Date
    Feb 2001
    Posts
    1,836
    yup yup, just learnt about that one not long ago studying java It's a join of both if and else!
    Streets Of Poker - Heads-Up Texas Hold'em Poker Game

  4. #4
    Senior Member charlie_says's Avatar
    Join Date
    Feb 2003
    Location
    UK
    Posts
    508
    thanks very much, knew it could be done, but never would have figured that out by myself.

  5. #5
    383,890,620 polygons nGFX's Avatar
    Join Date
    Oct 2002
    Location
    Germany / Ruhrgebiet
    Posts
    902
    ... and if someone has read the doc ... :

    var z = Math.max(x , y);




    <olli/>

  6. #6
    Senior Member
    Join Date
    Jun 2002
    Location
    Manchester, UK
    Posts
    2,357
    Is that faster????

    RipX

  7. #7
    Senior Member mbenney's Avatar
    Join Date
    Mar 2001
    Posts
    2,744
    yeah rip i think it is...

    i wish it would give the highest from any number of values

  8. #8
    383,890,620 polygons nGFX's Avatar
    Join Date
    Oct 2002
    Location
    Germany / Ruhrgebiet
    Posts
    902
    it is by far:

    10000 iterations:
    Math.max : 369ms
    (a<=b)? : 381ms



    <olli/>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center