Hello everybody! I need some help about arrays in the tcl language! I have to convert an integer number (num) into a binary number (bit120) of 120 bit. I have to put this binary number into an array of 120 elements. I tried in this way: for {set k 119} {$k <0} {set k [expr $k-1]} { #bit120 is the array of 120 bit that represent the converted integer number set bit120($k) [expr $num%2] set num [expr $num/2] } Is it right? Then I have to divide this array in six arrays of 20 elements, I tried in this way: Until the array is not finished take 20 bit from the 120 bit array (bit120) and put them into a smaller array (bit20) of 20 bit. set cont 0 while ($cont<120) { #cont is a counter that keeps trace of the position if the array, 0¡Ücont¡Ü120 set j 0 # j is the counter of the 20 bit array for {set i $cont} {$i <$cont+20} {incr i} { set bit20($j) $bit120($i) incr j } } The last thing I have to do is to convert this 20 bit array (bit20) into a integer number (num20), I tried in this way: set m 0 #m is the counter of the 20 bit array set n 19 set num20 0 #num20 is initialized to 0 while ($m<20) { set num20 [expr $num20+$bit20($n)*pow(2,$m)] incr m set n [expr $n-1] } Is it right? It gives me some problems when I run it on ns2. I don¡¯t know if I have defined in the right way the arrays or if there are some problems with the conversion. Give some advices, please! Thanks! Debora ---------------------------------
--------------------------------- L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail