Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/21/06 09:37
Read: times


 
#129886 - compiler
Responding to: ???'s previous message
Christoph Franck said:
It seems to do some strange things (I compiled it on my PC) that are probably related to the length of an integer on the target system.

Yes, I forgot to mention, I used a Win32 compiler (lcc) so int is generous 32 bit (yeah, that's one thing from that "why-I-hate-C" list - one never knows what int means...) - that's long int on a 16-bit (DOS) compiler.

You can change the width of output by changing value of n in main (n can be any integer but the resulting output number of bits are in powers of two, that's a property of this generating algorithm - yours or Erik's is more general and would work also for any other number of bits if that would be required).

I don't think nested loops are a real problem - these are just trivial for loops. This implementation might not compile too efficiently - I am really not a C-guru to be able to tune it to a particular processor - but I am quite convinced that it can be tuned up significantly by rewriting into asm and I also believe that it is more efficient than moving bits around on almost any platform, being it 8051, PC or anything else.

It would be nice to know the comparison of this and your algorithm (sort of a benchmark), speedwise, if it does not mean too much work for you.

JW


List of 40 messages in thread
TopicAuthorDate
Looking for an algorithm.            01/01/70 00:00      
   I'd split it in two (or 4)            01/01/70 00:00      
      I've shown, in increseing detail, how to do it            01/01/70 00:00      
   Sorted, or only counted?            01/01/70 00:00      
      Counting is enough            01/01/70 00:00      
         Not sorting or counting then??            01/01/70 00:00      
            My approach.            01/01/70 00:00      
               Erik's idea is fast and simple!            01/01/70 00:00      
   did you even consider what I posted            01/01/70 00:00      
      I considered lookup tables.            01/01/70 00:00      
         look at my code it is right there            01/01/70 00:00      
         Can you explain your table?            01/01/70 00:00      
            Interpret it in binary            01/01/70 00:00      
               Hhm...            01/01/70 00:00      
                  Use of the table/algorithm            01/01/70 00:00      
                  misunderstanding            01/01/70 00:00      
                     Ah. I thought so.            01/01/70 00:00      
            explanation of table            01/01/70 00:00      
   table lookup            01/01/70 00:00      
   now, I'm confused            01/01/70 00:00      
      The keyword is "enumerate".            01/01/70 00:00      
         i give up since nobody can answer in english            01/01/70 00:00      
            Meaning #1            01/01/70 00:00      
               there must be some language problem here            01/01/70 00:00      
                  Basically, a)            01/01/70 00:00      
                     then this will work (and I believe the fastest)            01/01/70 00:00      
                        maybe yes            01/01/70 00:00      
                           maybe faster, but not6 what he ned            01/01/70 00:00      
                              it's sometimes not easy to describe what one needs            01/01/70 00:00      
                                 Sorting or counting            01/01/70 00:00      
                                    Bit shifting            01/01/70 00:00      
                                    I elaborated.            01/01/70 00:00      
                                       Christoph, have you tried...            01/01/70 00:00      
                                          It looks interesting ..            01/01/70 00:00      
                                             well, you said that...            01/01/70 00:00      
                                                here you are            01/01/70 00:00      
                                                   Works.            01/01/70 00:00      
                                                      compiler            01/01/70 00:00      
                                                         Benchmark            01/01/70 00:00      
                                                            thanks!            01/01/70 00:00      

Back to Subject List