tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
6
Task/Binary-digits/Tcl/binary-digits-1.tcl
Normal file
6
Task/Binary-digits/Tcl/binary-digits-1.tcl
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
proc num2bin num {
|
||||
# Convert to _fixed width_ big-endian 32-bit binary
|
||||
binary scan [binary format "I" $num] "B*" binval
|
||||
# Strip useless leading zeros by reinterpreting as a big decimal integer
|
||||
scan $binval "%lld"
|
||||
}
|
||||
7
Task/Binary-digits/Tcl/binary-digits-2.tcl
Normal file
7
Task/Binary-digits/Tcl/binary-digits-2.tcl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
for {set x 0} {$x < 16} {incr x} {
|
||||
puts [num2bin $x]
|
||||
}
|
||||
puts "--------------"
|
||||
puts [num2bin 5]
|
||||
puts [num2bin 50]
|
||||
puts [num2bin 9000]
|
||||
Loading…
Add table
Add a link
Reference in a new issue