`On Wed, 31 Jan 2007, Vegard Nossum wrote:> On Tue, January 30, 2007 3:12 pm, Jan Engelhardt wrote:> >> >>> Why the qualifier? Zero *is* not a power of 2, is it?> >> > No, it is not:> >> > 	In[1]:= Solve[2^n == 0, n]> >> > 	Out[1]= {}> >> > So says Mathematica5.>> As a side note, I would just like to point out that Mathematica does> not deal with modular arithmetic by default (which programmers very> much do). In fact, in modular arithmetic, zero IS a power of two.>> 2^n = 0 (mod 2^n)>> To see if it holds for bytes, substitute n = 8, and you get 2^8 = 0> (mod 256). In other words: Zero is the eighth power of two modulo> 256.that's a bit esoteric but, yes, you make a good point.> Modular arithmetic is, however, very often a source of errors in> programming (unchecked-for overflows and underflows), and it is> questionable whether the programmer would really want 0 reported as> a power of two.precisely.   given the definition of "is_power_of_2()" that's beenpublished, some people will (quite correctly) point out that usingthat macro in place of the test "(n & (n - 1))" isn't quite the samething.  and they would be correct.but one wonders how many programmers have been using that very test"((n & (n - 1))" without realizing that it would accept zero, and thatit has been accepting zero all this time, perhaps leading to weird andinexplicable errors.rewriting that test as "is_power_of_2()" may, in fact, cause somethings to suddenly break, but perhaps those are things that shouldhave been *forced* to break anyway, to identify where the conditioncheck was incorrect all this time, and someone's just been lucky, orsomething like that.***NOTE***:  and that's why i suggested that the individualmaintainers might want to make this substitution themselves, to makesure everything continues to work.  because if you leave it as aproject for the kernel janitors, they might not realize what you hadin mind.  so it's in your best interest to start cleaning this up onyour own.just my \$0.02 (Cdn.)rday-- ========================================================================Robert P. J. DayLinux Consulting, Training and Annoying Kernel PedantryWaterloo, Ontario, CANADAhttp://www.fsdev.dreamhosters.com/wiki/index.php?title=Main_Page========================================================================-To unsubscribe from this list: send the line "unsubscribe linux-kernel" inthe body of a message to majordomo@vger.kernel.orgMore majordomo info at  http://vger.kernel.org/majordomo-info.htmlPlease read the FAQ at  http://www.tux.org/lkml/`