I added the [dubious – discuss] tag to the following
| This article is rated C-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||
| |||||||||||
I added the [dubious – discuss] tag to the following
In most cases, the programmer would choose the former method. If it was necessary to find the minimum of two integers millions of times per second, the programmer might exploit his knowledge of binary representation of integers and come up with the latter method. Since that method does not use branching, it runs faster on some processors.
Already the first part is not true, in most cases the programmer would use the MIN(x,y) macro implemented as (x<y)?x:y, or a min(x,y) procedure that would be inlined by the compiler and avoid duplicate evaluation of x,y if this would eb a concern. But the main problem is the last phrase; since so far I only know counter-examples providing evidence against the truth of the statement, so even if it is m-m-maybe conceivable that the idea could apply (and still, I could not think of a microprogram realizing that situation), if there is no commercially available CPU with this property, then I don't think it is relevant and the statement should better be removed since it would only create confusion in > 99% of the cases. For current processors as AMD and Pentium my tests provide evidence for the fact that (x<y)?x:y virtually takes no time (almost all of the time of the loop, being needed to decrement & zero test the counter and branch back), while the "complicated" solution takes over 20% of the total time.— MFH:Talk 15:59, 5 June 2008 (UTC)
The program snippet is an "obvious" division loop, but that's so very bad programmatically (2 divides per bit??) that I would never instruct anyone to do that. As an algorithm, yes, we may think of it that way, since a power of 2 is 2*2*...*2 and after casting away all the 2s, there'll be only a factor of 1 left. I wouldn't want to tempt someone to compile and actually run that program. I think just a technically concise text description, or a pseudocode snippet would adequately convey the idea. Then, we proceed to the bit-code to implement it, since that is what the article is about. The section drowns in the irrelevant example. Sbalfour (talk) 19:39, 13 November 2019 (UTC)
The article has too much context specific text: i.e. the C language, the GNU compiler, the X86 architecture. Bit manipulation has nothing to do with any of these. The article should focus on the operations, and what interesting results can be obtained elegantly and efficiently by use of them. If necessary, present expressions in an appropriate pseudocode or mathematical notation. The rest of the context stuff should vanish. Sbalfour (talk) 19:54, 13 November 2019 (UTC)
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.