| r236 vs r237 | ||
|---|---|---|
| ... | ... | |
| 20 | 20 | '''tu''' : temporary value 1 (integer); '''tv''' : temporary value 2 (integer); |
| 21 | 21 | '''tw''' : temporary value 3 (integer); '''tx''' : temporary value 4 (integer); |
| 22 | 22 | '''ty''' : temporary value 5 (integer); |
| 23 | '''pd''' : padding with zeros. (string) | |
| 23 | 24 | '''ps''' : pass (logical); '''ts''' : --not about gender-- test (logical) ; '''br''' : break (logical); |
| 24 | 25 | '''ea''' : error code about "a" (integer); '''eb''' : error code about "b" (integer); |
| 25 | 26 | '''wa''' : warning code about "a" (integer); '''wb''' : warning code about "b" (integer); |
| ... | ... | |
| 29 | 30 | |
| 30 | 31 | ##== 초기화 == |
| 31 | 32 | 값을 미리 정의하여 초기화합니다. 중간에 --장난으로-- 계산에 사용되는 변수에 값을 부여한 채로 include 하더라도 이를 무시합니다. |
| 32 | {{{#!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="" | |
| 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+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.pd="000000000000000000" | |
| 33 | 34 | }}}{{{#!if this.al=as.length, this.bl=bs.length, this.ad=as.indexOf("."), this.bd=bs.indexOf(".") |
| 34 | 35 | }}}{{{#!if ad!=-1 |
| 35 | 36 | 소수점이 발견되는 자리 번호가 ad이므로 ad+1번에 해당되는 자리부터 끝까지 표기합니다. |
| ... | ... | |
| 178 | 179 | ○○○○○○○○○□□□□○○□□○ 과 같이 9칸, 4칸, 2칸, 2칸, 1칸씩 차이가 나면 그 정도를 보정하게 됩니다. |
| 179 | 180 | ap>bp에서 ap-bp>0이 됩니다. ap-bp는 곧 ap가 bp보다 몇 칸만큼 더 많은지를 나타냅니다. |
| 180 | 181 | {{{#!if ap>bp |
| 181 | {{{#!if bp=ap, bb+= | |
| 182 | {{{#!if bp=ap, bb+=pd | |
| 182 | 183 | }}}{{{#!if bb=bb.substr(0,ap) |
| 183 | 184 | }}}}}} |
| 184 | 185 | |
| 185 | 186 | 반대로 b의 소수점 자릿수가 많은 경우도 있습니다. |
| 186 | 187 | {{{#!if bp>ap |
| 187 | {{{#!if ap=bp, ab=ab+ | |
| 188 | {{{#!if ap=bp, ab=ab+pd | |
| 188 | 189 | }}}{{{#!if ab=ab.substr(0,bp) |
| 189 | 190 | }}}}}} |
| 190 | 191 | |
| ... | ... | |
| 344 | 345 | +"000100"을 숫자로 바꾸면 100이 되는 문제가 있습니다. 이처럼 소수점 아래 자릿수를 연산한 결과를 문자열로 바꿨을 때 기존 소수점 아래 자릿수보다 작은 길이가 나오면 앞쪽에 0을 보충합니다. |
| 345 | 346 | 앞에서 ap,bp를 똑같이 맞췄으므로 ap를 가져옵니다. 자릿수가 모자랄 경우 0을 하나씩 보충합니다. |
| 346 | 347 | {{{#!if rp<ap |
| 347 | {{{#!if rb= | |
| 348 | {{{#!if rb=pd.substr(0,ap-rp)+rb | |
| 348 | 349 | }}}}}} |
| 349 | 350 | |
| 350 | 351 | 앞에 0을 채웠다면 이제, 소수점 아래로 나오는 숫자를 보고 마지막에서부터 0이 나오면 한 자리씩 지우는 과정을 시작합니다. |
| ... | ... | |
| 399 | 400 | |
| 400 | 401 | a와 b 각각 소수점 윗자리와 소수점 아래자리의 문자열의 빈 공간을 0으로 채워 18자로 만듭니다. |
| 401 | 402 | 소수점 윗자리는 왼쪽에서 0을 채워나갑니다. |
| 402 | {{{#!if au = | |
| 403 | {{{#!if au = pd + au | |
| 403 | 404 | +18자}}}{{{#!if au=au.substr(au.length-18,18) |
| 404 | 405 | }}} |
| 405 | {{{#!if bu = | |
| 406 | {{{#!if bu = pd + bu | |
| 406 | 407 | +18자}}}{{{#!if bu=bu.substr(bu.length-18,18) |
| 407 | 408 | }}} |
| 408 | 409 | |
| 409 | 410 | 소수점 아래자리는 오른쪽에서 0을 채웁니다. (ap, bp값은 보존됩니다.) |
| 410 | {{{#!if ab += | |
| 411 | {{{#!if ab += pd | |
| 411 | 412 | +18자}}}{{{#!if ab=ab.substr(0,18) |
| 412 | 413 | }}} |
| 413 | {{{#!if bb += | |
| 414 | {{{#!if bb += pd | |
| 414 | 415 | +18자}}}{{{#!if bb=bb.substr(0,18) |
| 415 | 416 | }}}}}} |
| 416 | 417 | |
| 417 | 418 | {{{#!if f=="/" |
| 418 | 419 | 나눗셈은 소수점 위 18번째 자리부터 내려가면서 처음으로 0이 아닌 숫자가 있으면 그 숫자가 처음 숫자가 되도록 숫자를 왼쪽으로 밀어두려고 합니다. 그 다음 오른쪽을 0으로 채웁니다. |
| 419 | 420 | au를 왼쪽으로 밀 경우 남게 되는 자릿수를 변수 tu로 둡니다. (후술할 아래 곱셈연산과 겹치지 않습니다.) |
| 420 | {{{#!if tu=18-au.length, au=au+ab.substr(0,tu)+ | |
| 421 | {{{#!if tu=18-au.length, au=au+ab.substr(0,tu)+pd, ab=ab.substr(tu)+pd, au=au.substr(0,18), ab=ab.substr(0,18) | |
| 421 | 422 | }}} |
| 422 | {{{#!if tu=18-bu.length, bu=bu+bb.substr(0,tu)+ | |
| 423 | {{{#!if tu=18-bu.length, bu=bu+bb.substr(0,tu)+pd, bb=bb.substr(tu)+pd, bu=bu.substr(0,18), bb=bb.substr(0,18) | |
| 423 | 424 | }}} |
| 424 | 425 | |
| 425 | 426 | }}} |
| ... | ... | |
| 1458 | 1459 | }}}{{{#!if rs==0 |
| 1459 | 1460 | {{{#!if rs="" |
| 1460 | 1461 | }}}}}}{{{#!if (f=="*")&&(rs>0) |
| 1461 | {{{#!if rs=rs.toString(), ru= | |
| 1462 | {{{#!if rs=rs.toString(), ru=pd+ru, ru=ru.substr(ru.length-18, 18) | |
| 1462 | 1463 | }}}}}} |
| 1463 | 1464 | |
| 1464 | 1465 | #rb 정리 부분 |
| ... | ... | |
| 1478 | 1479 | |
| 1479 | 1480 | 곱셈 과정에서 ri가 0보다 클 경우 rb를 문자열로 변환하고 rb, ri의 왼쪽을 0으로 채웁니다. |
| 1480 | 1481 | {{{#!if ps |
| 1481 | {{{#!if rb=rb.toString(), ri=ri.toString(), rb= | |
| 1482 | {{{#!if rb=rb.toString(), ri=ri.toString(), rb=pd+rb, rb=rb.substr(rb.length-18, 18), ri=pd+ri, ri=ri.substr(ri.length-18, 18) | |
| 1482 | 1483 | }}}}}} |
| 1483 | 1484 | |
| 1484 | 1485 | ri가 비었고 rb가 0이 아닌 경우 rb를 문자열로 바꾼 다음 왼쪽을 0으로 채웁니다. |
| 1485 | 1486 | {{{#!if !ps&&(rb>0) |
| 1486 | {{{#!if rb=rb.toString(), rb= | |
| 1487 | {{{#!if rb=rb.toString(), rb=pd+rb, rb=rb.substr(rb.length-18, 18) | |
| 1487 | 1488 | }}}}}} |
| 1488 | 1489 | |
| 1489 | 1490 | ps가 true이면 rp를 ri의 길이로, 그렇지 않고 rb만 0이 아닌경우 rp를 rb의 길이로 정의합니다. |
| ... | ... |