| r2 vs r3 | ||
|---|---|---|
| 1 | 1 | [[분류:냥]][[분류:계산용 틀]]{{{#!wiki style="display: none;" |
| 2 | ##디버그용 if 문법 ("문자열" 값으로 정의해야 합니다.) | |
| 3 | {{{#!if a= ,b= ,f=, md= | |
| 4 | }}} | |
| 5 | 2 | ##== 변수 설명 == |
| 6 | 3 | '''as''' : "a" value to string; '''bs''' : "b" value to string; |
| 7 | 4 | '''al''' : "a" string length (integer); '''bl''' : "b" string length (integer) |
| ... | ... | |
| 27 | 24 | '''ma''' : message about "a" (string); '''mb''' : message about "b" (string); |
| 28 | 25 | '''tm''' : temporary string, or transaction message (string); '''tn''' : temporary string 2 (string); |
| 29 | 26 | '''ns''' : negative sign for multiplication and division (string); |
| 30 | ||
| 31 | 27 | ##== 초기화 == |
| 32 | 값을 미리 정의하여 초기화합니다. 중간에 --장난으로-- 계산에 사용되는 변수에 값을 부여한 채로 include 하더라도 이를 무시합니다. | |
| 33 | 28 | {{{#!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+0, 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="", this.tn="", this.ms="", this.pd="000000000000000000" |
| 34 | 29 | }}}{{{#!if this.al=as.length, this.bl=bs.length, this.ad=as.indexOf("."), this.bd=bs.indexOf(".") |
| 35 | 30 | }}}{{{#!if ad!=-1 |
| 36 | 소수점이 발견되는 자리 번호가 ad이므로 ad+1번에 해당되는 자리부터 끝까지 표기합니다. | |
| 37 | 31 | {{{#!if this.au=as.substr(0,ad), this.ab=as.substr(ad+1, al-ad-1), this.ap=ab.length |
| 38 | 32 | }}}{{{#!if (au=="")||(au=="-")||(au=="+") |
| 39 | .12345 식으로 또는 -.12345 식으로 기입할 경우 upper 값을 0으로 부여합니다. | |
| 40 | 33 | {{{#!if au="0" |
| 41 | 34 | }}}}}}}}}{{{#!if ad==-1 |
| 42 | 소수점이 존재하지 않을 경우 au 문자열 길이값을 ad로 정의합니다. au의 마지막 문자열 index는 ad-1이 됩니다. | |
| 43 | 35 | {{{#!if this.au=as, ab="", ap=0+0, ad=au.length |
| 44 | 36 | }}}}}}{{{#!if bd!=-1 |
| 45 | 37 | {{{#!if this.bu=bs.substr(0,bd), this.bb=bs.substr(bd+1, bl-bd-1), this.bp=bb.length |
| ... | ... | |
| 48 | 40 | }}}}}}}}}{{{#!if bd==-1 |
| 49 | 41 | {{{#!if this.bu=bs, bb="", bp=0+0, bd=bu.length |
| 50 | 42 | }}}}}} |
| 51 | ||
| 52 | 43 | ##== 유효성 검사 == |
| 53 | the seed에서 지원되는 long(integer)가 unsigned였으면 1844경까지 가서 충분히 19자리로 놀 수 있었는데, signed long이므로 922경까지 가능한 공간에서 18자리로 잘라내기를 합니다. (소수점 위 최대 18자리, 소수점 아래 최대 18자리) | |
| 54 | ||
| 55 | (반점(,)을 자동적으로 생략하고 들어가는 것은 나중에 생각하겠습니다.) | |
| 56 | ||
| 57 | 44 | {{{#!if (as!=null)&&(bs!=null) |
| 58 | a와 b 모두 입력되었을 때, br와 ts 변수를 이용하여 순차적으로 검사를 진행합니다. 도중 문제가 있으면 (br를 true로 반환하고) 오류 코드를 내도록 만듭니다. a를 먼저 보며, 소수점 윗부분을 먼저 본 다음 소수점 아랫부분을 봅니다. | |
| 59 | 변수 tm와 tn을 가져와 유효성 검사를 실행합니다. | |
| 60 | 먼저 소수점을 2개 이상 입력했음이 탐지된다면 오류코드 5번(이중 소수점 표기)을 반환합니다. | |
| 61 | 소수점을 입력하면 indexOf와 lastIndexOf는 서로 다른 값을 가리키게 됩니다. 소수점을 입력하지 않았을 경우 indexOf와 lastIndexOf는 -1로 서로 같은 값을 가리키게 됩니다. | |
| 62 | 45 | {{{#!if ts=(as.indexOf(".")==as.lastIndexOf(".")), br=ts?br:true, ea=ts?0:5 |
| 63 | }}} | |
| 64 | ||
| 65 | ||
| 66 | ||
| 67 | {{{#!if ts&&!br | |
| 46 | }}}{{{#!if ts&&!br | |
| 68 | 47 | {{{#!if tm=(au[0]==45)?au.substr(1):au, ts=(tm.length<=18), br=ts?br:true, ea=ts?0:1 |
| 69 | }}}}}} | |
| 70 | ||
| 71 | ||
| 72 | ||
| 73 | {{{#!if ts&&!br | |
| 48 | }}}}}}{{{#!if ts&&!br | |
| 74 | 49 | {{{#!if tm="1"+tm, tn=+tm, tn=tn.toString(), ts=(tm==tn), br=ts?br:true, ea=ts?0:6 |
| 75 | }}}}}} | |
| 76 | ||
| 77 | ||
| 78 | ||
| 79 | {{{#!if ts&&!br | |
| 50 | }}}}}}{{{#!if ts&&!br | |
| 80 | 51 | {{{#!if ab.length>=19 |
| 81 | 52 | {{{#!if wa=1, ab=ab.substr(0,18), ap=18 |
| 82 | }}}}}} | |
| 83 | ||
| 84 | ||
| 85 | {{{#!if ts=(((ab[0]==null)||((ab[0]>=48)&&(ab[0]<=57)))&&((ab[1]==null)||((ab[1]>=48)&&(ab[1]<=57)))&&((ab[2]==null)||((ab[2]>=48)&&(ab[2]<=57)))&&((ab[3]==null)||((ab[3]>=48)&&(ab[3]<=57)))&&((ab[4]==null)||((ab[4]>=48)&&(ab[4]<=57)))&&((ab[5]==null)||((ab[5]>=48)&&(ab[5]<=57)))&&((ab[6]==null)||((ab[6]>=48)&&(ab[6]<=57)))&&((ab[7]==null)||((ab[7]>=48)&&(ab[7]<=57)))&&((ab[8]==null)||((ab[8]>=48)&&(ab[8]<=57)))&&((ab[9]==null)||((ab[9]>=48)&&(ab[9]<=57)))&&((ab[10]==null)||((ab[10]>=48)&&(ab[10]<=57)))&&((ab[11]==null)||((ab[11]>=48)&&(ab[11]<=57)))&&((ab[12]==null)||((ab[12]>=48)&&(ab[12]<=57)))&&((ab[13]==null)||((ab[13]>=48)&&(ab[13]<=57)))&&((ab[14]==null)||((ab[14]>=48)&&(ab[14]<=57)))&&((ab[15]==null)||((ab[15]>=48)&&(ab[15]<=57)))&&((ab[16]==null)||((ab[16]>=48)&&(ab[16]<=57)))&&((ab[17]==null)||((ab[17]>=48)&&(ab[17]<=57)))) | |
| 86 | ||
| 87 | ||
| 88 | ||
| 89 | }}}}}} | |
| 90 | ||
| 91 | ||
| 92 | ||
| 93 | {{{#!if br=false, ts=(bs.indexOf(".")==bs.lastIndexOf(".")), br=ts?br:true, eb=ts?0:5 | |
| 94 | }}} | |
| 95 | {{{#!if ts&&!br | |
| 53 | }}}}}}{{{#!if ts=(((ab[0]==null)||((ab[0]>=48)&&(ab[0]<=57)))&&((ab[1]==null)||((ab[1]>=48)&&(ab[1]<=57)))&&((ab[2]==null)||((ab[2]>=48)&&(ab[2]<=57)))&&((ab[3]==null)||((ab[3]>=48)&&(ab[3]<=57)))&&((ab[4]==null)||((ab[4]>=48)&&(ab[4]<=57)))&&((ab[5]==null)||((ab[5]>=48)&&(ab[5]<=57)))&&((ab[6]==null)||((ab[6]>=48)&&(ab[6]<=57)))&&((ab[7]==null)||((ab[7]>=48)&&(ab[7]<=57)))&&((ab[8]==null)||((ab[8]>=48)&&(ab[8]<=57)))&&((ab[9]==null)||((ab[9]>=48)&&(ab[9]<=57)))&&((ab[10]==null)||((ab[10]>=48)&&(ab[10]<=57)))&&((ab[11]==null)||((ab[11]>=48)&&(ab[11]<=57)))&&((ab[12]==null)||((ab[12]>=48)&&(ab[12]<=57)))&&((ab[13]==null)||((ab[13]>=48)&&(ab[13]<=57)))&&((ab[14]==null)||((ab[14]>=48)&&(ab[14]<=57)))&&((ab[15]==null)||((ab[15]>=48)&&(ab[15]<=57)))&&((ab[16]==null)||((ab[16]>=48)&&(ab[16]<=57)))&&((ab[17]==null)||((ab[17]>=48)&&(ab[17]<=57)))), br=ts?br:true, ea=ts?0:7 | |
| 54 | }}}}}}{{{#!if br=false, ts=(bs.indexOf(".")==bs.lastIndexOf(".")), br=ts?br:true, eb=ts?0:5 | |
| 55 | }}}{{{#!if ts&&!br | |
| 96 | 56 | {{{#!if tm=(bu[0]==45)?bu.substr(1):bu, ts=(tm.length<=18), br=ts?br:true, eb=ts?0:1 |
| 97 | }}}}}} | |
| 98 | {{{#!if ts&&!br | |
| 57 | }}}}}}{{{#!if ts&&!br | |
| 99 | 58 | {{{#!if tm="1"+tm, tn=+tm, tn=tn.toString(), ts=(tm==tn), br=ts?br:true, eb=ts?0:6 |
| 100 | }}}}}} | |
| 101 | {{{#!if ts&&!br | |
| 59 | }}}}}}{{{#!if ts&&!br | |
| 102 | 60 | {{{#!if bb.length>=19 |
| 103 | 61 | {{{#!if wb=1, bb=bb.substr(0,18), bp=18 |
| 104 | 62 | }}}}}}{{{#!if ts=(((bb[0]==null)||((bb[0]>=48)&&(bb[0]<=57)))&&((bb[1]==null)||((bb[1]>=48)&&(bb[1]<=57)))&&((bb[2]==null)||((bb[2]>=48)&&(bb[2]<=57)))&&((bb[3]==null)||((bb[3]>=48)&&(bb[3]<=57)))&&((bb[4]==null)||((bb[4]>=48)&&(bb[4]<=57)))&&((bb[5]==null)||((bb[5]>=48)&&(bb[5]<=57)))&&((bb[6]==null)||((bb[6]>=48)&&(bb[6]<=57)))&&((bb[7]==null)||((bb[7]>=48)&&(bb[7]<=57)))&&((bb[8]==null)||((bb[8]>=48)&&(bb[8]<=57)))&&((bb[9]==null)||((bb[9]>=48)&&(bb[9]<=57)))&&((bb[10]==null)||((bb[10]>=48)&&(bb[10]<=57)))&&((bb[11]==null)||((bb[11]>=48)&&(bb[11]<=57)))&&((bb[12]==null)||((bb[12]>=48)&&(bb[12]<=57)))&&((bb[13]==null)||((bb[13]>=48)&&(bb[13]<=57)))&&((bb[14]==null)||((bb[14]>=48)&&(bb[14]<=57)))&&((bb[15]==null)||((bb[15]>=48)&&(bb[15]<=57)))&&((bb[16]==null)||((bb[16]>=48)&&(bb[16]<=57)))&&((bb[17]==null)||((bb[17]>=48)&&(bb[17]<=57)))), br=ts?br:true, eb=ts?0:7 |
| ... | ... |