Posted to tcl by karen at Sun Jan 31 19:34:55 GMT 2021view raw
- #helper func: converts decimal input to binary output
- proc dec2bin i {
- #returns a string, e.g. dec2bin 10 => 1010
- set res {}
- while {$i>0} {
- set res [expr {$i%2}]$res
- set i [expr {$i/2}]
- }
- if {$res == {}} {set res 0}
- return $res
- }