08-19-2003, 03:04 AM
Take a closer peek at neo's example:
this is the equivalent of Log 2 n, the solution for 2^x = n. if you say: int(log(number&) / log(2)) you get the number of digits.
so if you're using a dynamic array:
dim scraparray(200) as integer '<- oughta be enough
'do your thing
redim myarray(int(log(number&) / log(2))
then copy your array.
of course, an easier way to do it would be:
and then curdigit is the number of digits used.
and to whitetiger: you could do that conversion 1000 times in your program, and some of those things I did roll over into other areas of programming, so it's a good habit to use them.
EDIT: nuts, I misunderstood your question. BRB
Code:
LOG(number&) / LOG(2)
this is the equivalent of Log 2 n, the solution for 2^x = n. if you say: int(log(number&) / log(2)) you get the number of digits.
so if you're using a dynamic array:
dim scraparray(200) as integer '<- oughta be enough
'do your thing
redim myarray(int(log(number&) / log(2))
then copy your array.
of course, an easier way to do it would be:
Code:
cudigit = 0
while number& <> 0
if number& and 1 then array(curdigit) = 1 else array(curdigit = 0
number& = number& \ 2
curdigit = curdigit + 1
wend
and then curdigit is the number of digits used.
and to whitetiger: you could do that conversion 1000 times in your program, and some of those things I did roll over into other areas of programming, so it's a good habit to use them.
EDIT: nuts, I misunderstood your question. BRB