> . . . . . I suspect that calculating 2^j is rather time consuming
> and would like to test other/faster methods . . . . .
>> . . . . . I suspect that calculating 2^j is rather time consuming
>> and would like to test other/faster methods . . . . .
[quoted text clipped - 4 lines]
>it. If you want a faster method though you could do a lot worse than a
>simple look up table (which on testing is about a hundred times faster):
Mike is right. And didn't Donald Knuth say premature optimization is
the root of all evil?
Having said that, (and noting that programmer time is more expensive
than computer time), you could take advantage of the fact that
2^n=n*n, because multiplication can be faster than exponentials. But
the best thing would be to precalculate it using an array/table - and
trade speed for memory space.
Have you done the *timing*? Premature optimization is "EVIL".
>Option Explicit
>Private Bit(0 To 15) As Long
[quoted text clipped - 14 lines]
>
>Mike
_______________________
Michael B. Johnson
Jon - 18 May 2004 16:15 GMT
snip
| Having said that, (and noting that programmer time is more expensive
| than computer time), you could take advantage of the fact that
| 2^n=n*n, because multiplication can be faster than exponentials. But
| the best thing would be to precalculate it using an array/table - and
| trade speed for memory space.
2^n is not n*n, that would be n^2
2^n = 2 * 2 * 2 (with n twos)
:)
Jon
Michael B. Johnson - 30 Jun 2004 17:00 GMT
>| Having said that, (and noting that programmer time is more expensive
>| than computer time), you could take advantage of the fact that
[quoted text clipped - 9 lines]
>
>Jon
Quite right. Thanks, Jon for correcting my oversight.
_______________________
Michael B. Johnson
_______________________
Michael B. Johnson