Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting 2 variables: one ascending, one descending
#21
NEO: The XOR solution is exactly what I was hinting at. Another gold star for you, Neo. Here's a piece of code from an old program of mine which does exactly this.
Code:
complement:             'Complement each key byte for DESCENDING
  for zz = 1 to len(k$)
      mid$(k$,zz,1) = chr$( asc(mid$(k$,zz,1)) XOR 255 )
  next zz
RETURN     '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
An XOR of any byte with 255 will produce the complement of the original byte value. This is known as the one's complement, which means that every 1 becomes a 0, and every 0 becomes a 1.

MEG: Thanks for letting TOOH have it with both barrels. Yes I'm posting from Mexico City. Timezone-wise that's the same time as Chicago. I don't post at strange times, usually at night when I get home from work.

About the sayings. The Turkish one I got from my first mother-in-law who was a Greek born in Istanbul. She quoted this saying all the time as being Turkish. Let's keep in mind that this lady was born in 1900, so the saying could be outdated.
The one about singing out of the same hymm book comes from an American saying that a person who is not 100% mentally, is "not singing out of the same hymm book". This saying too may be outdated since I'm 66 years old and can't remember how long ago I heard it. It is real, however.

I love old sayings. A programmer friend of mine called Mick, who was born in Texas, used to quote sayings from his mother all the time. My favorite was: "Im so tired, I feel like I've been ironing all day with a cold iron¨. You've got to hear it with a Texas drawl.
*****
Reply


Messages In This Thread
My Submission - by Meg - 11-08-2004, 10:26 PM
Hey!.. - by ToohTooh - 11-08-2004, 11:16 PM
Now this is serious. - by ToohTooh - 11-10-2004, 07:13 PM
Sorting 2 variables: one ascending, one descending - by Moneo - 11-12-2004, 08:55 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)