Prev: PC = Personal Copier :)
Next: x86 instruction set usage-difference between windows 95 andwindows xp ?
From: Skybuck Flying on 28 May 2010 09:44 "MitchAlsup" <MitchAlsup(a)aol.com> wrote in message news:50cf86e3-63e1-4405-8989-ef475ad4ca2b(a)y21g2000vba.googlegroups.com... On May 27, 11:06 am, "Skybuck Flying" <IntoTheFut...(a)hotmail.com> wrote: > Would you rather write: > > // 1. > Z := X shl Y; > > // or > > // 2. > if Y < 32 then > begin > Z := X shl Y; > end else > begin > Z := X; > end; " Why not: z = x << (y & 31); " This won't work for a bitmask that needs to have all bits set to one. However I found a solution and posted it in another sub thread. No branch needed for masks as long as bitcount is always greater than zero ! ;) The trick is to use constant "-2" and "(bitcount-1)" See subthread for full formula ! ;) :) Bye, Skybuck.
From: Robert Myers on 28 May 2010 12:30 On May 28, 7:32 am, Terje Mathisen <"terje.mathisen at tmsw.no"> wrote: > James Dow Allen wrote: > > > I am *not* here to defend anal-retentive coding. > > ("Hello, my name is James and I indulge in silly > > pointless micro-optimizations.") But surely everyone > > It is never pointless: I learn something every time. > > > will admit that micro-optimizations are a cheaper > > and safer *recreation* than many alternatives. :-) > > Absolutely. > > I've been helping a guy who crossposted an optimization problem over a > bunch of programming groups (I read it in comp.lang.asm.x86). > > His original program took 26 minutes (albeit a number of years ago), he > has a third-party written version which runs in ~5 ms, but sometimes > fails to work (i.e. doesn't find all solutions). > > My current code runs in 0.75 ms, and he's still complaining because I > wrote it in C(++) instead of his preferred Pascal. :-) Just saw another orienteering competition in progress, Terje. Very safe, except possibly for a sprain or an abrasion from a slip and fall on the rocky terrain. I once managed to get my foot infected from something in my shoe, even though I wasn't orienteering. Most important, if someone is overly-clever or overreaching, the consequences for anyone else will be strictly limited. The national guard and police helicopters are unlikely to be engaged in even the most dire conceivable mishap. I'm not sure you can say the same for compulsively-optimizing hotshot programmers. Maybe you could get more of them interested in orienteering, or some similar mentally and physically challenging activity that will leave less time for obscure cleverness. As to learning something from almost anything that requires thought, who could disagree? ;-) Robert.
From: Nathan on 28 May 2010 14:20 On May 27, 11:33 am, Seebs <usenet-nos...(a)seebs.net> wrote: > On 2010-05-27, Skybuck Flying <IntoTheFut...(a)hotmail.com> wrote: > > > The lookup table right now seems to be the best solution for 32 bit support. > > I think at this point I'm plonking you. You're extremely verbose without > saying much of anything, you overuse exclamation marks, you're overly > exciteable, and apparently you don't have any clue how to frame a problem, > think about what you need, and develop a plan for approaching it. Maybe > you should consider decaf. > Hmm... "overly excitable" might be indicative of bipolar-ism. The rest might be attributable to a "need for attention" which overpowers his desire to learn. One item in his favor is a persistent willingness to play with code. Nathan.
From: Robert Myers on 28 May 2010 15:09 On May 28, 2:20 pm, Nathan <nathancba...(a)gmail.com> wrote: > > One item in his favor is a persistent willingness to play with code. > Forgive my idle chatter. Playing with any kind of puzzle or challenging activity can always be productive. One of the things that's attractive about applied mathematics as I have experienced it is that, if something goes well, "as if by magic," it's usually an indication that you have done something right, and perhaps very right. There are exceptions, but the fact that something "works out" is almost always a trail of bread crumbs worth following. That has not been my experience with programming, either my own, or the programming of others. Too many things in programming will work out "as if by magic" under some circumstances and not others. That's one of the roots of evil in the mess that is called computer science. Robert.
From: Terje Mathisen "terje.mathisen at on 28 May 2010 16:12
Robert Myers wrote: > One of the things that's attractive about applied mathematics as I > have experienced it is that, if something goes well, "as if by magic," > it's usually an indication that you have done something right, and > perhaps very right. There are exceptions, but the fact that something > "works out" is almost always a trail of bread crumbs worth following. > > That has not been my experience with programming, either my own, or > the programming of others. Too many things in programming will work > out "as if by magic" under some circumstances and not others. That's > one of the roots of evil in the mess that is called computer science. Not quite true: Several of my most cherished programs/functions/algorithms, those I consider really elegant, have exactly the ssame feeling of rightness about them: All the parts fit together, all the corner cases simply go away, and the performance is close to optimal as well. Terje -- - <Terje.Mathisen at tmsw.no> "almost all programming can be viewed as an exercise in caching" |