| r217 vs r218 | ||
|---|---|---|
| ... | ... | |
| 3 | 3 | {{{#!if a= ,b= ,f= |
| 4 | 4 | }}} |
| 5 | 5 | {{{#!wiki style="display: none; display: inline;" |
| 6 | ##== | |
| 6 | ##== 변수 설명 == | |
| 7 | 7 | '''as''' : "a" value to string; '''bs''' : "b" value to string; |
| 8 | 8 | '''al''' : "a" string length (integer); '''bl''' : "b" string length (integer) |
| 9 | 9 | '''ad''' : "a" decimal point (integer); '''bd''' : "b" decimal point (integer); |
| ... | ... | |
| 17 | 17 | '''ru''' : "result" upper value (integer→string); '''rb''' : "result" below value (integer→string); |
| 18 | 18 | '''rp''' : "result" # of places of decimal (integer); |
| 19 | 19 | '''rs''' : "result" suprerior value (integer→string); '''ri''' : "result" inferior value (integer→string); |
| 20 | '''i''' : index; | |
| 20 | '''i''' : index; | |
| 21 | '''tu''' : temporary value 1 (integer); '''tv''' : temporary value 2 (integer); | |
| 22 | '''tw''' : temporary value 3 (integer); '''tx''' : temporary value 4 (integer); | |
| 23 | '''ty''' : temporary value 5 (integer); | |
| 21 | 24 | '''ps''' : pass (logical); '''ts''' : --not about gender-- test (logical) ; '''br''' : break (logical); |
| 22 | '''ea''' : error about "a"; '''eb''' : error about "b"; | |
| 23 | '''wa''' : warning about "a" ; '''wb''' : warning about "b" ; | |
| 25 | '''ea''' : error code about "a" (integer); '''eb''' : error code about "b" (integer); | |
| 26 | '''wa''' : warning code about "a" (integer); '''wb''' : warning code about "b" (integer); | |
| 27 | '''ma''' : message about "a" (string); '''mb''' : message about "b" (string); | |
| 28 | '''tm''' : temporary string, or transaction message (string); '''tn''' : temporary string 2 (string); | |
| 24 | 29 | '''ns''' : negative sign for multiplication and division (string); |
| 25 | {{{#!if this.as=a.toString(), this.bs=b.toString(), this.rs=0+0, this.ru=0+0, this.rb=0+0, this.ri=0+0, this.rp=0+0, this.i=0+0, this.tu=0, this.tv=1, this.tw=0, this.tx=0, this.ty=0, this.ea=0+0, this.eb=0+0, this.wa=0+0, this.wb=0+0, this.ps=false, this.ts=false, this.br=false, ns="" | |
| 30 | ||
| 31 | ##== 초기화 == | |
| 32 | 값을 미리 정의하여 초기화합니다. 중간에 --장난으로-- 계산에 사용되는 변수에 값을 부여한 채로 include 하더라도 이를 무시합니다. | |
| 33 | {{{#!if this.as=a.toString(), this.bs=b.toString(), this.rs=0+0, this.ru=0+0, this.rb=0+0, this.ri=0+0, this.rp=0+0, this.i=0+0, this.tu=0, this.tv=1, this.tw=0, this.tx=0, this.ty=0, this.ea=0+0, this.eb=0+0, this.wa=0+0, this.wb=0+0, this.ps=false, this.ts=false, this.br=false, this.ns="", this.ma="", this.mb="", this.tm="" | |
| 26 | 34 | }}}{{{#!if this.al=as.length, this.bl=bs.length, this.ad=as.indexOf("."), this.bd=bs.indexOf(".") |
| 27 | 35 | }}}{{{#!if ad!=-1 |
| 28 | 36 | 소수점이 발견되는 자리 번호가 ad이므로 ad+1번에 해당되는 자리부터 끝까지 표기합니다. |
| ... | ... | |
| 41 | 49 | {{{#!if this.bu=bs, bb="", bp=0+0, bd=bu.length |
| 42 | 50 | }}}}}} |
| 43 | 51 | |
| 44 | 입력한 소수점 아래에 입력한 값을 정리합니다. 이에 따라 ap, bp값도 다시 조정됩니다. | |
| 45 | {{{#!if ap>9, ab.substr(ap-9,9)=="000000000" | |
| 46 | {{{#!if ab=ab.substr(0,rp-9), ap=ap-9 | |
| 47 | }}}}}} | |
| 48 | {{{#!if ap>4, ab.substr(ap-4,4)=="0000" | |
| 49 | {{{#!if ab=ab.substr(0,ap-4), ap=ap-4 | |
| 50 | }}}}}} | |
| 51 | {{{#!if ap>2, ab.substr(ap-2,2)=="00" | |
| 52 | {{{#!if ab=ab.substr(0,ap-2), ap=ap-2 | |
| 53 | }}}}}} | |
| 54 | {{{#!if ap>2, ab.substr(ap-2,2)=="00" | |
| 55 | {{{#!if ab=ab.substr(0,ap-2), ap=ap-2 | |
| 56 | }}}}}} | |
| 57 | {{{#!if ap>1, ab.substr(ap-1,1)=="0" | |
| 58 | {{{#!if ab=ab.substr(0,ap-1), ap=ap-1 | |
| 59 | }}}}}} | |
| 60 | {{{#!if bp>9, bb.substr(bp-9,9)=="000000000" | |
| 61 | {{{#!if bb=bb.substr(0,rp-9), bp=bp-9 | |
| 62 | }}}}}} | |
| 63 | {{{#!if bp>4, bb.substr(bp-4,4)=="0000" | |
| 64 | {{{#!if bb=bb.substr(0,bp-4), bp=bp-4 | |
| 65 | }}}}}} | |
| 66 | {{{#!if bp>2, bb.substr(bp-2,2)=="00" | |
| 67 | {{{#!if bb=bb.substr(0,bp-2), bp=bp-2 | |
| 68 | }}}}}} | |
| 69 | {{{#!if bp>2, bb.substr(bp-2,2)=="00" | |
| 70 | {{{#!if bb=bb.substr(0,bp-2), bp=bp-2 | |
| 71 | }}}}}} | |
| 72 | {{{#!if bp>1, bb.substr(bp-1,1)=="0" | |
| 73 | {{{#!if bb=bb.substr(0,bp-1), bp=bp-1 | |
| 74 | }}}}}} | |
| 75 | ||
| 76 | 52 | ##== 유효성 검사 == |
| 77 | 53 | the seed에서 지원되는 long(integer)가 unsigned였으면 1844경까지 가서 충분히 19자리로 놀 수 있었는데, signed long이므로 922경까지 가능한 공간에서 18자리로 잘라내기. 소수점 위 최대 18자리, 소수점 아래 최대 18자리 |
| 78 | 54 | {{{#!if ((au[0]!=45)&&(au.length>=19))||((au[0]==45)&&(au.length>=20)) |
| ... | ... | |
| 96 | 72 | (반점(,)을 자동적으로 생략하고 들어가는 것은 나중에 생각하겠습니다.) |
| 97 | 73 | {{{#!if false |
| 98 | 74 | br와 ts 변수를 이용하여 순차적으로 검사를 진행합니다. 도중 문제가 있으면 (br를 true로 반환하고) 오류 코드를 내도록 만듭니다. |
| 75 | ||
| 76 | 소수점 윗자릿수가 넘치면 오류코드 1번(오버플로)를 반환합니다. | |
| 99 | 77 | {{{#!if ts=((au[0]!=45)&&(au.length<=18))||((au[0]==45)&&(au.length<=19)) |
| 100 | 78 | }}}{{{#!if !ts&&!br |
| 101 | 79 | {{{#!if br=true, ea=1 |
| 102 | 80 | }}}}}} |
| 103 | 소수점 | |
| 81 | ||
| 82 | 소수점을 2개 이상 입력하면 오류코드 5번을 반환합니다. | |
| 104 | 83 | {{{#!if ts&&!br |
| 105 | 84 | {{{#!if ts=(as.indexOf(".")==as.lastIndexOf(".")) |
| 106 | 85 | }}}}}}{{{#!if !ts&&!bk |
| 107 | 86 | {{{#!if br=true, ea=5 |
| 108 | 87 | }}}}}} |
| 109 | ||
| 88 | ||
| 89 | 숫자가 아닌 이상한 문구를 섞어넣을 경우 오류코드 6번을 반환합니다. (임시로 변수 tm과 tn를 가져옵니다.) | |
| 110 | 90 | {{{#!if ts&&!br |
| 111 | ||
| 112 | {{{#!if | |
| 113 | ||
| 114 | ||
| 115 | ||
| 116 | ||
| 117 | {{{#!if t | |
| 118 | ||
| 119 | ||
| 91 | {{{#!if tm=au, tm[0]==45 | |
| 92 | {{{#!if tm=tm.substr(1, tm.length-1) | |
| 120 | 93 | }}}}}} |
| 121 | {{{#!if | |
| 122 | ||
| 123 | ||
| 124 | ||
| 94 | {{{#!if tm="1"+tm, tn=+tm, tn=tn.toString(), ts=(tm==tn) | |
| 125 | 95 | }}}}}} |
| 96 | {{{#!if !ts&&!br | |
| 97 | {{{#!if br=true, ea=6 | |
| 98 | }}}}}} | |
| 99 | ||
| 100 | {{{#!if ts&&!br | |
| 126 | 101 | }}} |
| 102 | }}} | |
| 127 | 103 | error code 05 번 ~ : 입력한 변수는 숫자로 읽을 수 없습니다. |
| 128 | 104 | * 5번 : 반점(,)을 입력했다면 반점을 지우고 다시 입력하세요. |
| 129 | 105 | |
| 130 | 106 | error code 03 번 : 0으로 나눌 수 없습니다.(아래쪽 참고) |
| 131 | 107 | |
| 108 | ##== 2차 초기화 == | |
| 109 | 입력한 소수점 아래에 입력한 값을 정리합니다. 이에 따라 ap, bp값도 다시 조정됩니다. | |
| 110 | {{{#!if ap>9, ab.substr(ap-9,9)=="000000000" | |
| 111 | {{{#!if ab=ab.substr(0,rp-9), ap=ap-9 | |
| 112 | }}}}}} | |
| 113 | {{{#!if ap>4, ab.substr(ap-4,4)=="0000" | |
| 114 | {{{#!if ab=ab.substr(0,ap-4), ap=ap-4 | |
| 115 | }}}}}} | |
| 116 | {{{#!if ap>2, ab.substr(ap-2,2)=="00" | |
| 117 | {{{#!if ab=ab.substr(0,ap-2), ap=ap-2 | |
| 118 | }}}}}} | |
| 119 | {{{#!if ap>2, ab.substr(ap-2,2)=="00" | |
| 120 | {{{#!if ab=ab.substr(0,ap-2), ap=ap-2 | |
| 121 | }}}}}} | |
| 122 | {{{#!if ap>1, ab.substr(ap-1,1)=="0" | |
| 123 | {{{#!if ab=ab.substr(0,ap-1), ap=ap-1 | |
| 124 | }}}}}} | |
| 125 | {{{#!if bp>9, bb.substr(bp-9,9)=="000000000" | |
| 126 | {{{#!if bb=bb.substr(0,rp-9), bp=bp-9 | |
| 127 | }}}}}} | |
| 128 | {{{#!if bp>4, bb.substr(bp-4,4)=="0000" | |
| 129 | {{{#!if bb=bb.substr(0,bp-4), bp=bp-4 | |
| 130 | }}}}}} | |
| 131 | {{{#!if bp>2, bb.substr(bp-2,2)=="00" | |
| 132 | {{{#!if bb=bb.substr(0,bp-2), bp=bp-2 | |
| 133 | }}}}}} | |
| 134 | {{{#!if bp>2, bb.substr(bp-2,2)=="00" | |
| 135 | {{{#!if bb=bb.substr(0,bp-2), bp=bp-2 | |
| 136 | }}}}}} | |
| 137 | {{{#!if bp>1, bb.substr(bp-1,1)=="0" | |
| 138 | {{{#!if bb=bb.substr(0,bp-1), bp=bp-1 | |
| 139 | }}}}}} | |
| 132 | 140 | |
| 133 | 141 | ##== 덧셈, 뺄셈 == |
| 134 | 142 | 덧셈과 뺄셈 계산과정을 적어봅니다. |
| ... | ... |