| r141 vs r142 | ||
|---|---|---|
| ... | ... | |
| 18 | 18 | '''rs''' : "result" suprerior value (integer→string); '''ri''' : "result" inferior value (integer→string); |
| 19 | 19 | '''i''' : index; '''tv''' temporary value 1 (integer); '''tw''' temporary value 2 (integer); '''ps''' : pass (logical); |
| 20 | 20 | '''ea''' : error about "a"; '''eb''' : error about "b"; '''wa''' : warning about "a" ; '''wb''' : warning about "b" ; |
| 21 | {{{#!if this.as=a.toString(), this.bs=b.toString(), this.ru=0+0, this.rb=0+0, this.rp=0+0, this.i=0+0, this.tv=1, this.tw=0, this.ea=0+0, this.eb=0+0, this.wa=0+0, this.wb=0+0 | |
| 22 | }}}{{{#!if this.al=as.length, this.bl=bs.length, this.ad=as.indexOf("."), this.bd=bs.indexOf(".") | |
| 21 | {{{#!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.tv=1, this.tw=0, this.ea=0+0, this.eb=0+0, this.wa=0+0, this.wb=0+0 | |
| 22 | }}}{{{#!if this.al=as.length, this.bl=bs.length, this.ad=as.indexOf("."), this.bd=bs.indexOf(".") | |
| 23 | 23 | }}}{{{#!if ad!=-1 |
| 24 | 24 | 소수점이 발견되는 자리 번호가 ad이므로 ad+1번에 해당되는 자리부터 끝까지 표기합니다. |
| 25 | 25 | {{{#!if this.au=as.substr(0,ad), this.ab=as.substr(ad+1, al-ad-1), this.ap=ab.length |
| ... | ... | |
| 679 | 679 | 변수 tw를 가져옵니다. (tv는 1로 초기화 된 채로 있습니다.) |
| 680 | 680 | 소수점 아래 18자리의 아래인 제19~36번 자리를 ri로 둡니다. |
| 681 | 681 | ri에서 자릿수가 넘치면 넘친 만큼을 rb로 넘기고, rb에서 자릿수가 넘치면 넘친 만큼을 ru로 넘깁니다. ru에서 자릿수가 넘치면 rs로 넘깁니다. |
| 682 | {{{#!if tw= | |
| 682 | ||
| 683 | ○○○○○○○○○○○○○○○○○○□□□□□□□□□□□□□□□□□□.■■■■■■■■■■■■■■■■■■●●●●●●●●●●●●●●●●●● | |
| 684 | 이를테면 소수점 아래 19~36번 자리에서 18자리가 된 ab 문자열 전체를 숫자로 바꾸고 bb의 문자열의 마지막 (18번째) 자리의 값을 곱한 값을 더합니다. | |
| 685 | {{{#!if tw=ab.substr(0,18), tw=(+tw)*(+bb.substr(17,1)), tw=tw.toString() | |
| 683 | 686 | }}} |
| 687 | 18자리에서 넘쳐 19자리가 되면 넘친 앞의 1자리를 rb로 넘기고 나머지 18자리를 ri에 더합니다. | |
| 688 | {{{#!if tw.length==19 | |
| 689 | {{{#if rb=(+rb)+(+tw.substr(0,1)), ri=(+ri)+((+tw.substr(1,18))*tv) | |
| 690 | }}}}}}{{{#!if tw.length<=18 | |
| 691 | {{{#!if ri=ri+((+tw)*tv) | |
| 692 | }}}}}} | |
| 684 | 693 | |
| 694 | 앞으로 있을 계산으로 | |
| 695 | * ri를 더했더니 ri가 19자리 숫자로 넘치면 넘친 앞의 1자리를 rb로 넘깁니다. | |
| 696 | * 이렇게 했더니 rb가 19자리로 넘쳤다면 넘친 앞의 1자리를 ru로 넘깁니다. | |
| 697 | * 이렇게 1자리를 ru로 넘겼는데 ru가 19자리로 넘친다면 넘친 앞의 1자리를 rs로 넘깁니다. | |
| 698 | (rs는 상용로그로 보았을 때 log a<18, log b<18 에서 log (a*b) = log a + log b < 36이므로 19자리로 넘치지 않습니다.) | |
| 699 | 문자열로 바꾸고 문자열을 쪼갠 다음 숫자로 바꾸는 과정입니다. 이를 if로 바꾸면 다음과 같습니다. | |
| 700 | {{{#!if ri=ri.toString(), ri.length==19 | |
| 701 | {{{#if rb=(+rb)+(+ri.substr(0,1)), ri=(+ri.substr(1,18)) | |
| 702 | }}}}}} | |
| 703 | {{{#!if rb=rb.toString(), rb.length==19 | |
| 704 | {{{#if ru=(+ru)+(+rb.substr(0,1)), rb=(+rb.substr(1,18)) | |
| 705 | }}}}}} | |
| 706 | {{{#!if ru=ru.toString(), ru.length==19 | |
| 707 | {{{#if rs=(+rs)+(+ru.substr(0,1)), ru=(+ru.substr(1,18)) | |
| 708 | }}}}}} | |
| 685 | 709 | |
| 686 | 710 | |
| 711 | ||
| 712 | ||
| 687 | 713 | 여기까지가 a*b 계산과정입니다. |
| 688 | 714 | }}} |
| 689 | 715 | |
| ... | ... |