Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
2
#tclsh 8.6 #proc dec2bin int { # set binRep [binary format c $int] # binary scan $binRep B* binStr # return $binStr #} proc dec2bin i { set res {} while {$i>0} { set res [expr {$i%2}]$res set i [expr {$i/2}] } if {$res == {}} {set res 0} return $res } set v1 10 set v2 10 set a [expr abs($v1)] puts $a if { $v1 == $a } { set M [ dec2bin $a ] puts $M set b [split $M ""] puts $b set B {} foreach x $b { lappend B "[expr !$x]" } set m [dec2bin [expr [join 0b$B ""] + 1]] puts [join $B ""] puts $m } else { set M 0b[ dec2bin $a ] set m 0b[ dec2bin $v1 ] } #puts $M #puts $m set q "[ dec2bin $v2 ]" puts q$q set A 0b00000000 set n 4 set s {} set AQ {} #while {$n != 0} { set q0 [lindex [split $q ""] 7 ] puts $q0 lappend s $q0 puts $s set q1 [lindex [split $q ""] 6 ] puts $q1 lappend s $q1 puts $s set Q [join $s ""] puts $Q if { $Q == 01 } { set A [dec2bin [expr $A + $M]] puts $A lappend AQ $A puts $AQ lappend AQ $q set Y [join $AQ ""] puts $Y set Z [expr $Y << 1] puts $Z } #set n [expr $n -1] #}
run
|
edit
|
history
|
help
0
Perfect decimal to binary add
Different factorial implementations
Trail
Dec to binary addition
Perfect bin mul eo float
fl mul bin
procedures.tcl
3
Trying bin mul floating point
Dec to binary addition