Re: [PATCH] Add "is_power_of_2" checking to log2.h.

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jan Engelhardt <jengelh@...>
Cc: Robert P. J. Day <rpjday@...>, Nick Piggin <nickpiggin@...>, Linux kernel mailing list <linux-kernel@...>, Andrew Morton <akpm@...>, Paul Mackerras <paulus@...>, <dhowells@...>, <galak@...>
Date: Wednesday, January 31, 2007 - 6:13 am

On Tue, January 30, 2007 3:12 pm, Jan Engelhardt wrote:

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.

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.


Vegard

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Add "is_power_of_2" checking to log2.h., Robert P. J. Day, (Tue Jan 30, 7:06 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Mariusz Kozlowski, (Tue Feb 20, 11:29 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Kumar Gala, (Tue Feb 20, 11:56 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Mariusz Kozlowski, (Tue Feb 20, 12:14 pm)
Re: [PATCH] Add "is_power_of_2" checking to log2.h. , David Howells, (Thu Feb 1, 6:43 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h. , Tim Schmielau, (Thu Feb 1, 8:39 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Tim Schmielau, (Thu Feb 1, 5:55 pm)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Robert P. J. Day, (Thu Feb 1, 6:49 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Nick Piggin, (Tue Jan 30, 8:25 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h. , David Howells, (Thu Feb 1, 6:41 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Robert P. J. Day, (Tue Jan 30, 8:56 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Nick Piggin, (Tue Jan 30, 9:21 pm)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Robert P. J. Day, (Wed Jan 31, 3:20 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Jan Engelhardt, (Tue Jan 30, 10:12 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Vegard Nossum, (Wed Jan 31, 6:13 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Robert P. J. Day, (Wed Jan 31, 6:47 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Robert P. J. Day, (Tue Jan 30, 10:45 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., H. Peter Anvin, (Mon Jun 11, 7:11 pm)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Jan Engelhardt, (Tue Jan 30, 11:50 am)
Re: [PATCH] Add "is_power_of_2" checking to log2.h., Robert P. J. Day, (Tue Jan 30, 12:00 pm)