Re: 1st and 2nd.... positions

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



See inline comments....

I really enjoy tinkering like this.

I definitely got that impression.

I like the threads where we occasionally "go deep"! We can all
learn from these types of idea exchanges and it makes us better.

Agreed! In the seven plus years I have been volunteering answering newsgroup questions... the "go deep" threads are the ones I always hope will come up.

I've searched the web (a few times in the past) and *every* version of this formula (up till now) is significantly longer (and/or doesn't work for any number!). It took your posting the idea of searching a string for the correct position (Brilliant!) to give me a nudge.

Not sure about the "brilliant" part, but I am glad to have done my part in bringing about a new solution to an old problem. The trick of using the Mid function to perform non-linear lookups is an old one for me. I started with conputers back in 1981, developed a sort of expertise in BASIC language programming and use it as the basis for some dozen plus articles I had published in various computer magazines throughout the 1980s. In January 1985, I had an article showing how to do a screen dump from a Radio Shack Model 100 computer (the first, true laptop). From that article...

"Try as I might, I was unable to find any combination of mathematical or logical operators which would convert the Model 100's binary code into the mirror image required by the Epson printer. I finally settled on the MID$ function, putting the codes for the printer into a string in reverse order."

I then when on to explain how to use the MID$ function to map numerical relationships into ordered return values. However, I had already been using the idea behind this technique for some 3 plus years prior to the publication of my article. Hey, do you think maybe I "invented" this technique?<g>

You may be interested to know that these 2 versions had considerably different calc times:

=A1&MID("thstndrdthththththth",1+2*RIGHT(A1)*(ABS(MOD(A1,100)-12)>1),2)

=A1&MID("thstndrdth",MIN(9,2*RIGHT(A1)*(ABS(MOD(A1,100)-12)>1)+1),2)

The 2nd one was much faster even though it has an additional function call.

I find this result very hard to believe. Look at the two formulas... with the exception of the location of the +1, each one evaluates the **indentical** expression, but the second one embeds it within a MIN function call. Can the shorter main text string in the second formula really add significantly to the efficiency of performing the MID function call that it can compensate for the extra function call? I find it real hard to imagine that is the case.

The same basic formula can be easily modified for use on ordinal days of the month (dates) and is *still* shorter and better than the "standards" (including the one I've used in the past).

Great... maybe my posting that usage for the MID function will open up a whole new batch of more efficient (or at least more compact) replacements for existing solutions.

Rick

.



Relevant Pages

  • Re: Secure C programming
    ... So take the case of the string functions. ... my code uses strcpy to stuff it into a buffer. ... but efficiency in processing them. ...
    (comp.lang.c)
  • Re: Encode combination efficiently
    ... wrong the average bits/element will be around 12.54 bits/element with ... could end the string out in at least two different ways. ... shorter strings to make them all the same length. ... I know you have a hatred of bijective compression but this ...
    (comp.compression)
  • Re: Cheap multi-color LED Christmas light strings.
    ... 50 lights for $10 per string. ... the AC line cycle, and with 50 LEDs in series, they needed ... Efficiency of the LEDs vary with instantaneous current. ... during low current operation that impairs the reds and greens. ...
    (sci.electronics.design)
  • Re: Replacement Strat Machineheads
    ... > Two are the same lengths as the original tuners and four are shorter - ... > especially on the D string. ... > four shorter tuners were for the strings that go via the trees with the ... string angle for the higher 4 strings and eliminate the string trees for a ...
    (rec.music.makers.guitar)
  • Re: Using Trim in a Userform
    ... Well, if you want to do this without calling the WorksheetFunction property, then I would use this much shorter macro... ... Function StripExtraSpaces(ByVal InputString As String) As String ...
    (microsoft.public.excel.programming)