Version 0 of to.binary

Updated 2003-12-04 19:18:58

proc to.binary n {

  incr n 0
  set r ""
  while {$n > 0} { 
   set r [expr {$n & 1}]$r
   set n [expr {$n >> 1}]
  } 
  return $r
 }

Example:

 % to.binary 3
 11
 % to.binary 4
 100
 % to.binary 200
 11001000