r236 vs r237
......
2020
'''tu''' : temporary value 1 (integer); '''tv''' : temporary value 2 (integer);
2121
'''tw''' : temporary value 3 (integer); '''tx''' : temporary value 4 (integer);
2222
'''ty''' : temporary value 5 (integer);
23
'''pd''' : padding with zeros. (string)
2324
'''ps''' : pass (logical); '''ts''' : --not about gender-- test (logical) ; '''br''' : break (logical);
2425
'''ea''' : error code about "a" (integer); '''eb''' : error code about "b" (integer);
2526
'''wa''' : warning code about "a" (integer); '''wb''' : warning code about "b" (integer);
......
2930
3031
##== 초기화 ==
3132
값을 미리 정의하여 초기화합니다. 중간에 --장난으로-- 계산에 사용되는 변수에 값을 부여한 채로 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"
3334
}}}{{{#!if this.al=as.length, this.bl=bs.length, this.ad=as.indexOf("."), this.bd=bs.indexOf(".")
3435
}}}{{{#!if ad!=-1
3536
소수점이 발견되는 자리 번호가 ad이므로 ad+1번에 해당되는 자리부터 끝까지 표기합니다.
......
178179
○○○○○○○○○□□□□○○□□○ 과 같이 9칸, 4칸, 2칸, 2칸, 1칸씩 차이가 나면 그 정도를 보정하게 됩니다.
179180
ap>bp에서 ap-bp>0이 됩니다. ap-bp는 곧 ap가 bp보다 몇 칸만큼 더 많은지를 나타냅니다.
180181
{{{#!if ap>bp
181
{{{#!if bp=ap, bb+="000000000000000000"
182
{{{#!if bp=ap, bb+=pd
182183
}}}{{{#!if bb=bb.substr(0,ap)
183184
}}}}}}
184185
185186
반대로 b의 소수점 자릿수가 많은 경우도 있습니다.
186187
{{{#!if bp>ap
187
{{{#!if ap=bp, ab=ab+"000000000000000000"
188
{{{#!if ap=bp, ab=ab+pd
188189
}}}{{{#!if ab=ab.substr(0,bp)
189190
}}}}}}
190191
......
344345
+"000100"을 숫자로 바꾸면 100이 되는 문제가 있습니다. 이처럼 소수점 아래 자릿수를 연산한 결과를 문자열로 바꿨을 때 기존 소수점 아래 자릿수보다 작은 길이가 나오면 앞쪽에 0을 보충합니다.
345346
앞에서 ap,bp를 똑같이 맞췄으므로 ap를 가져옵니다. 자릿수가 모자랄 경우 0을 하나씩 보충합니다.
346347
{{{#!if rp<ap
347
{{{#!if rb="000000000000000000".substr(0,ap-rp)+rb
348
{{{#!if rb=pd.substr(0,ap-rp)+rb
348349
}}}}}}
349350
350351
앞에 0을 채웠다면 이제, 소수점 아래로 나오는 숫자를 보고 마지막에서부터 0이 나오면 한 자리씩 지우는 과정을 시작합니다.
......
399400
400401
a와 b 각각 소수점 윗자리와 소수점 아래자리의 문자열의 빈 공간을 0으로 채워 18자로 만듭니다.
401402
소수점 윗자리는 왼쪽에서 0을 채워나갑니다.
402
{{{#!if au = "000000000000000000" + au
403
{{{#!if au = pd + au
403404
+18자}}}{{{#!if au=au.substr(au.length-18,18)
404405
}}}
405
{{{#!if bu = "000000000000000000" + bu
406
{{{#!if bu = pd + bu
406407
+18자}}}{{{#!if bu=bu.substr(bu.length-18,18)
407408
}}}
408409
409410
소수점 아래자리는 오른쪽에서 0을 채웁니다. (ap, bp값은 보존됩니다.)
410
{{{#!if ab += "000000000000000000"
411
{{{#!if ab += pd
411412
+18자}}}{{{#!if ab=ab.substr(0,18)
412413
}}}
413
{{{#!if bb += "000000000000000000"
414
{{{#!if bb += pd
414415
+18자}}}{{{#!if bb=bb.substr(0,18)
415416
}}}}}}
416417
417418
{{{#!if f=="/"
418419
나눗셈은 소수점 위 18번째 자리부터 내려가면서 처음으로 0이 아닌 숫자가 있으면 그 숫자가 처음 숫자가 되도록 숫자를 왼쪽으로 밀어두려고 합니다. 그 다음 오른쪽을 0으로 채웁니다.
419420
au를 왼쪽으로 밀 경우 남게 되는 자릿수를 변수 tu로 둡니다. (후술할 아래 곱셈연산과 겹치지 않습니다.)
420
{{{#!if tu=18-au.length, au=au+ab.substr(0,tu)+"000000000000000000", ab=ab.substr(tu)+"000000000000000000", au=au.substr(0,18), ab=ab.substr(0,18)
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)
421422
}}}
422
{{{#!if tu=18-bu.length, bu=bu+bb.substr(0,tu)+"000000000000000000", bb=bb.substr(tu)+"000000000000000000", bu=bu.substr(0,18), bb=bb.substr(0,18)
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)
423424
}}}
424425
425426
}}}
......
14581459
}}}{{{#!if rs==0
14591460
{{{#!if rs=""
14601461
}}}}}}{{{#!if (f=="*")&&(rs>0)
1461
{{{#!if rs=rs.toString(), ru="000000000000000000"+ru, ru=ru.substr(ru.length-18, 18)
1462
{{{#!if rs=rs.toString(), ru=pd+ru, ru=ru.substr(ru.length-18, 18)
14621463
}}}}}}
14631464
14641465
#rb 정리 부분
......
14781479
14791480
곱셈 과정에서 ri가 0보다 클 경우 rb를 문자열로 변환하고 rb, ri의 왼쪽을 0으로 채웁니다.
14801481
{{{#!if ps
1481
{{{#!if rb=rb.toString(), ri=ri.toString(), rb="000000000000000000"+rb, rb=rb.substr(rb.length-18, 18), ri="000000000000000000"+ri, ri=ri.substr(ri.length-18, 18)
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)
14821483
}}}}}}
14831484
14841485
ri가 비었고 rb가 0이 아닌 경우 rb를 문자열로 바꾼 다음 왼쪽을 0으로 채웁니다.
14851486
{{{#!if !ps&&(rb>0)
1486
{{{#!if rb=rb.toString(), rb="000000000000000000"+rb, rb=rb.substr(rb.length-18, 18)
1487
{{{#!if rb=rb.toString(), rb=pd+rb, rb=rb.substr(rb.length-18, 18)
14871488
}}}}}}
14881489
14891490
ps가 true이면 rp를 ri의 길이로, 그렇지 않고 rb만 0이 아닌경우 rp를 rb의 길이로 정의합니다.
......