LogIn E-mail
설계이야기
[Tcl]bi2int
# 43 JMJS    02.11.29 18:29

proc bi2int ain {
        global zout
        set ain [split $ain ""]
        set zout 0
        foreach a $ain {
                set zout [expr $zout * 2]
                if {$a=="1"} {
                        set zout [expr $zout + 1]
                }
        }
}

proc int2bi ain {
        global zout
        set zout ""
        if {$ain == 0} {
                set zout "0"
        } else {
                while {$ain != 0} {
                        set i [expr $ain % 2]
                        set zout "$i$zout"
                        set ain [expr ($ain - $i) /2]
                }
        }
}

bi2int "0000"
puts $zout
int2bi $zout
puts $zout

bi2int "0011"
puts $zout
int2bi $zout
puts $zout

bi2int "0111"
puts $zout
int2bi $zout
puts $zout

bi2int "1111"
puts $zout
int2bi $zout
puts $zout

게시물: 105 건, 현재: 1 / 2 쪽
[1] [2]
번호 제       목 작성자 등록일 방문
108  convert mogrify JMJS 20.2.28 141
107  [sh]array JMJS 19.8.14 191
106  arithmetic in a makefile, shell pwd export JMJS 17.9.8 4245
105  Split and merge large files JMJS 16.3.21 815
104  [Makefile]random JMJS 14.12.5 1238
100  윈도우7 용량부족 winsxs 폴더 최적화 JMJS 14.10.14 2160
99  [sh,csh]while loop JMJS 13.2.6 2210
98  hostname, hostid, /sbin/ifconfig eth0 JMJS 13.1.4 4232
97  [linux]fedora 16 gome-shell extension JMJS 12.3.12 1932
96  [linux]fedora 16 grub boot order change JMJS 12.3.10 2136
95  [linux]fedora Input Method,ibus,hangul JMJS 12.3.8 1827
94  [linux]audio,mp3,mplayer,gstreamer,vlc JMJS 12.3.7 2557
93  [sh].wrapper example JMJS 11.6.15 2119
92  [make]for loop JMJS 11.9.8 1830
91  [make]conditional expression JMJS 11.5.12 1714
90  [make]shell 실행 JMJS 11.3.9 1832
89  [wish]jplot JMJS 10.5.12 1494
88  yum JMJS 09.8.12 1518
87  [CYGWIN]X setup하기 JMJS 10.8.6 2881
86  [Make]Makefile Brief JMJS 10.8.6 1560
85  ldd /user/bin/xterm JMJS 09.4.24 1243
84  [HTML]어도비 SVG 뷰어와 HTML JMJS 09.4.24 1818
83  [DOS]DOS command JMJS 09.7.20 1484
82  [DOS]DOS command brief JMJS 07.2.21 1971
81  웹페이지 소스보기 JMJS 09.4.24 1498
80  [html]자동으로 글자색 바뀜 JMJS 07.1.10 1451
79  [html]복사, 드래그 금지 JMJS 07.1.10 1938
78  [csh]cshell에서 function 못쓴다네요 JMJS 11.3.17 1515
77  리눅스에서 i386,i586,i686, x86의 차이점 JMJS 06.10.16 1732
76  [CSH]$status JMJS 06.8.21 1200
75  [sh]substr, read, until,IFS,for,dirname JMJS 14.12.19 1394
74  [sh]rgbview.sh . hello.sh JMJS 10.11.30 1309
73  automount - /etc/fstab JMJS 06.2.23 1339
72  lmutil.csh JMJS 05.11.8 1664
71  화일이름에 못오는 문자 JMJS 05.9.8 1471
70  /usr/ucb /usr/ccs JMJS 05.9.5 1324
69  Solaris Version JMJS 05.9.5 1546
68  /usr/ccs/bin/nm -x debpli.so JMJS 05.8.31 1815
67  tar, gzip, zcat, uncompress, mn(.a 파일보기) JMJS 13.1.6 1671
66  find . -name -print -exec perl JMJS 09.4.17 1614
65  pkgadd -d packagefile JMJS 05.5.9 1376
64  prstat JMJS 08.10.2 1615
63  vi 명령어, vim명령어 gvim JMJS 11.2.11 4858
62  multiple directory 에서 grep ? JMJS 04.5.31 1760
61  [csh].cshrc_axis JMJS 04.5.14 1663
60  [csh].cshrc_modelsim JMJS 04.5.14 1746
59  [csh].cshrc_cadence JMJS 04.5.14 1803
58  [csh].cshrc_novas JMJS 04.5.14 1709
57  [csh].cshrc_verisity JMJS 04.5.14 2055
56  lmgrd JMJS 09.6.22 2398
55  [csh]which case JMJS 04.5.14 1660
54  [bash]example 2 JMJS 04.5.12 1920
53  [bash]example 1 JMJS 04.5.12 1759
52  fedora 12에서 touchpad disable JMJS 11.1.17 1847
51  [Perl]한국어 인코딩 JMJS 04.1.16 2647
50  [Perl]HTML에서 기호 표시를 위한 문자치환 JMJS 04.1.5 10986
49  [csh]make awk JMJS 03.6.6 2049
48  [csh]wordsplit JMJS 03.6.6 1679
47  [csh]vi2 JMJS 03.6.6 1508
46  [csh]cat.csh JMJS 03.6.6 1586
45  [csh]chgword.csh JMJS 03.6.6 1509
44  [bash]password JMJS 11.3.9 1436
43  [Tcl]bi2int JMJS 02.11.29 1425
42  [PC]ask 검색창이 자꾸 뜬다면 JMJS 09.4.24 1966
41  [csh]backup_copyc.csh; foreach; continue JMJS 09.4.24 1604
40  uname, uname -s -r, uname -p, uname -a JMJS 09.4.24 1804
39  [tk]새 창 열고 닫기 예제 JMJS 09.4.24 11401
38  [sh]if [[ "$abc" == "abc" && "$bbc" == "bbc" ]]; ... JMJS 11.3.17 1515
37  [expect]expect_scp.exp JMJS 11.3.9 1602
36  ssh -x -l soc lion scp -r ... JMJS 11.3.9 1395
35  TclTk 배열 JMJS 09.7.20 1506
34  ./configure make make install JMJS 11.1.13 1391
33  [csh]diff JMJS 10.7.14 1474
32  tr abc 123 < file1 > file2 JMJS 11.4.11 1424
31  Installing RPMforge JMJS 10.2.8 1519
30  [태그]글자색이 사라짐 JMJS 09.4.24 1577
29  [태그]자동으로 글자색이 변함 JMJS 09.4.24 1562
28  글자태그 모음 JMJS 09.4.24 1698
27  색상명과 RGB값 표 JMJS 09.4.24 1716
26  RGB 색상표 JMJS 09.4.24 1878
25  한글특수문자표 JMJS 09.4.24 1855
24  bc -l JMJS 01.5.22 1447
23  file *,  od -xc *, cat * JMJS 01.3.28 1773
22  Linux Memo JMJS 09.7.20 1611
21  xterm -fn 10x20 & JMJS 12.3.7 1460
20  W/S Tip JMJS 09.4.29 1538
19  [awk]example JMJS 10.10.30 1781
18  [csh].cshrc JMJS 11.6.21 2332
17  stop & background job JMJS 00.11.14 1395
16  W/S shout down JMJS 00.11.14 1418
15  [sed]example JMJS 16.9.5 1785
14  [DOS]Memo JMJS 00.10.29 1538
13  [csh]리스트를 만들어 foreach로 처리할때 JMJS 00.10.7 5412
12  [Tcl]Tool Command Language JMJS 09.7.24 2946
11  [csh]vi.csh JMJS 00.6.27 1514
10  [csh]Check Process JMJS 00.6.27 1463
9  [csh]Get Character and get char without 'return' JMJS 10.2.8 1581
8  [csh]foreach SED JMJS 00.6.27 1895
7  [Window]오류보고 안 뜨게하는 방법 JMJS 09.9.23 1470
6  [csh]echo.csh JMJS 00.6.27 1631
[1] [2]