Compare values

Results 1 to 3 of 3

Thread: Compare values

  1. #1
    Mojo Jojo Guest

    Default Compare values

    Is there some function of comparing 3 numbers and gerring the median<BR><BR>ie<BR><BR>12, 345,657 returns 345<BR><BR>2345, 5674567,12341 returns 2345<BR><BR>thanks

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default I dont think there is one

    i think you have to do it the hard way<BR><BR>Why dont you ask the powerpuff girls :)

  3. #3
    Join Date
    Dec 1969

    Default RE: Compare values

    If it&#039s only 3 numbers, just use brute force.<BR><BR>If it&#039s an unknown (and possibly large) number, the only way is to put the numbers in an array, sort the array, and pick the middle entry.<BR><BR>For three numbers:<BR><BR>&#060;%<BR>n1 = 315<BR>n2 = 778<BR>n3 = 981<BR><BR>If n1 &#062; n2 Then<BR>&nbsp; &nbsp; If n2 &#062; n3 Then<BR>&nbsp; &nbsp; &nbsp; &nbsp; median = n2<BR>&nbsp; &nbsp; ElseIf n3 &#062; n1 Then<BR>&nbsp; &nbsp; &nbsp; &nbsp; median = n1<BR>&nbsp; &nbsp; Else &#039 n3 must be between n1 and n2<BR>&nbsp; &nbsp; &nbsp; &nbsp; median = n3<BR>Else &#039 n2 &#062;= n1<BR>&nbsp; &nbsp; If n1 &#062; n3 Then<BR>&nbsp; &nbsp; &nbsp; &nbsp; median = n1<BR>&nbsp; &nbsp; ElseIf n3 &#062; n2 Then<BR>&nbsp; &nbsp; &nbsp; &nbsp; median = n2<BR>&nbsp; &nbsp; Else &#039 n3 must be between n1 and n2<BR>&nbsp; &nbsp; &nbsp; &nbsp; median = n3<BR>End If<BR>%&#062;<BR>

Posting Permissions

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