According to Brian F. Feldman:
-O lets you do explicit inlining, and -O2 enables -finline-functions.
You meant -O3 of course.
-O3Optimize yet more. This turns on everything -O2
does, along with also turning on -finline-func-
tions.
--
Ollivier
Mark Murray scribbled this message on Aug 22:
Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.
1 - 1
2,3 - 2
4,5,6,7 - 4
8,9,10,11,12,13,14,15 - 8
etc.
John-Mark Gurney wrote:
Shift a bit until it becomes greater than (or less than) the number
in question.
ummm, didn't you read his post?? he wanted a O(1) routine, NOT a O(n)
routine...
That technique is O(ln(n)), where n is the number in question.
Frankly, for numbers up to 32, a
According to Brian F. Feldman:
-O lets you do explicit inlining, and -O2 enables -finline-functions.
You meant -O3 of course.
-O3Optimize yet more. This turns on everything -O2
does, along with also turning on -finline-func-
tions.
--
Ollivier
Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.
1 - 1
2,3 - 2
4,5,6,7 - 4
8,9,10,11,12,13,14,15 - 8
etc.
So %1101 should become either %1 or %1000.
Shift a
Mark Murray scribbled this message on Aug 22:
Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.
1 - 1
2,3 - 2
4,5,6,7 - 4
8,9,10,11,12,13,14,15 - 8
etc.
It seems that all the solutions are too generic and slow. As I only have
to check the numbers 0-32 (actually 1-32), a block of if statements is
almost as fast as a table look up in 33 elements.
Cheers,
Nick
On Sun, 22 Aug 1999, Mark Murray wrote:
Does anyone know an inexpensive algorithm
John-Mark Gurney wrote:
Shift a bit until it becomes greater than (or less than) the number
in question.
ummm, didn't you read his post?? he wanted a O(1) routine, NOT a O(n)
routine...
That technique is O(ln(n)), where n is the number in question.
Frankly, for numbers up to 32, a
It seems that all the solutions are too generic and slow. As I only have
to check the numbers 0-32 (actually 1-32), a block of if statements is
almost as fast as a table look up in 33 elements.
I doubt it - use the table for a small fixed size set then
use Warner's (n) ? (1 (ffs(n) - 1)) : 0.
Daniel C. Sobral d...@newsguy.com wrote
That technique is O(ln(n)), where n is the number in question.
Frankly, for numbers up to 32, a table will wield the best results,
and might actually be smaller than some of the suggestions given so
far.
Counting n as bit, it is O(n) :p
Unrolling
Unfortunately the kernel is compiled with -O which does not include
inlining (dunno about explicit inlining, but don't think so).
Nick
On Sun, 22 Aug 1999, Peter Dufault wrote:
It seems that all the solutions are too generic and slow. As I only have
to check the numbers 0-32 (actually
--- Kazufumi-MIT-Mitani m...@mit-s.otaru-uc.ac.jp skrev:
Daniel C. Sobral d...@newsguy.com wrote
That technique is O(ln(n)), where n is the number in question.
Frankly, for numbers up to 32, a table will wield the best results,
and might actually be smaller than some of the
Peter Dufault wrote:
It seems that all the solutions are too generic and slow. As I only have
to check the numbers 0-32 (actually 1-32), a block of if statements is
almost as fast as a table look up in 33 elements.
I doubt it - use the table for a small fixed size set then
use Warner's
On Sun, 22 Aug 1999, Nick Hibma wrote:
Unfortunately the kernel is compiled with -O which does not include
inlining (dunno about explicit inlining, but don't think so).
Nick
-O lets you do explicit inlining, and -O2 enables -finline-functions.
Anyway, I think the simple solution to the
The best I can come up with is this:
/* kk+1 k
* given n, return 2 such that 2 n = 2
*/
inline unsigned long
n2power2(unsigned long n)
{
/* `smear' the highest set bit to the right */
n |= n1; n |= n2; n |= n4; n |= n8; n |= n16;
G'day Nick,
Nick Hibma [EMAIL PROTECTED] wrote:
Does anyone know an inexpensive algorithm (O(1)) to go from
an number to the next (lower or higher) power of two.
1 - 1
2,3 - 2
4,5,6,7 - 4
8,9,10,11,12,13,14,15 - 8
etc.
So
Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.
1 - 1
2,3 - 2
4,5,6,7 - 4
8,9,10,11,12,13,14,15 - 8
etc.
So %1101 should become either %1 or %1000.
The
Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.
1 - 1
2,3 - 2
4,5,6,7 - 4
8,9,10,11,12,13,14,15 - 8
etc.
So %1101 should become either %1 or %1000.
The
At Sat, 21 Aug 1999 12:54:32 +0200, Nick Hibma wrote:
Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.
1 - 1
2,3- 2
4,5,6,7- 4
8,9,10,11,12,13,14,15 - 8
etc.
So
In message [EMAIL PROTECTED] Nick Hibma writes:
: Does anyone know an inexpensive algorithm (O(1)) to go from an number to
: the next (lower or higher) power of two.
1 ffs(x)
Warner
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message
Nick Hibma scribbled this message on Aug 21:
Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.
1 - 1
2,3 - 2
4,5,6,7 - 4
8,9,10,11,12,13,14,15 - 8
etc.
So %1101
Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.
1 - 1
2,3 - 2
4,5,6,7 - 4
8,9,10,11,12,13,14,15 - 8
etc.
So %1101 should become either %1 or %1000.
The only
G'day Nick,
Nick Hibma n_hi...@skylink.it wrote:
Does anyone know an inexpensive algorithm (O(1)) to go from
an number to the next (lower or higher) power of two.
1 - 1
2,3 - 2
4,5,6,7 - 4
8,9,10,11,12,13,14,15 - 8
etc.
So
Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.
1 - 1
2,3 - 2
4,5,6,7 - 4
8,9,10,11,12,13,14,15 - 8
etc.
So %1101 should become either %1 or %1000.
The
Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.
1 - 1
2,3 - 2
4,5,6,7 - 4
8,9,10,11,12,13,14,15 - 8
etc.
So %1101 should become either %1 or %1000.
The
At Sat, 21 Aug 1999 12:54:32 +0200, Nick Hibma wrote:
Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.
1 - 1
2,3- 2
4,5,6,7- 4
8,9,10,11,12,13,14,15 - 8
etc.
So
On 21-Aug-99 Nick Hibma wrote:
Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.
1 - 1
2,3 - 2
4,5,6,7 - 4
8,9,10,11,12,13,14,15 - 8
etc.
So %1101 should
In message pine.bsf.4.10.9908211250310.7595-100...@heidi.plazza.it Nick Hibma
writes:
: Does anyone know an inexpensive algorithm (O(1)) to go from an number to
: the next (lower or higher) power of two.
1 ffs(x)
Warner
To Unsubscribe: send mail to majord...@freebsd.org
with unsubscribe
Nick Hibma scribbled this message on Aug 21:
Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.
1 - 1
2,3 - 2
4,5,6,7 - 4
8,9,10,11,12,13,14,15 - 8
etc.
So %1101
29 matches
Mail list logo