| r140 vs r141 | ||
|---|---|---|
| ... | ... | |
| 16 | 16 | '''ru''' : "result" upper value (integer→string); '''rb''' : "result" below value (integer→string); |
| 17 | 17 | '''rp''' : "result" # of places of decimal (integer); |
| 18 | 18 | '''rs''' : "result" suprerior value (integer→string); '''ri''' : "result" inferior value (integer→string); |
| 19 | '''i''' : index; '''tv''' temporary value; '''ps''' : pass (logical); | |
| 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.ea=0+0, this.eb=0+0, this.wa=0+0, this.wb=0+0 | |
| 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 | 22 | }}}{{{#!if this.al=as.length, this.bl=bs.length, this.ad=as.indexOf("."), this.bd=bs.indexOf("."), this.rs="", this.ri="" |
| 23 | 23 | }}}{{{#!if ad!=-1 |
| 24 | 24 | 소수점이 발견되는 자리 번호가 ad이므로 ad+1번에 해당되는 자리부터 끝까지 표기합니다. |
| ... | ... | |
| 516 | 516 | 0을 곱하면 0이 되므로, a와 b 모두 0이 아닌 값을 곱할 때를 봅니다. |
| 517 | 517 | {{{#!if ((+au!=0)||(+ab!=0))&&((+bu!=0)||(+bb!=0)) |
| 518 | 518 | |
| 519 | 소수점 아래 자리가 존재하는 경우 소수점 아래 자리를 먼저 연산합니다. 그렇지 않은 경우 소수점 윗부분을 연산합니다. | |
| 520 | {{{#!if (ap>0)||(bp>0) | |
| 521 | 소수점 아래 자릿수가 있는 숫자끼리 곱한 결과는 일반적으로 자릿수+자릿수만큼 소수점 아래 자릿수가 늘어납니다. java long으로 해볼 수 있는 자릿수가 18자리이므로 ap+bp값이 18을 넘어갈 경우 제19번 자리수부터 생각해야 합니다. | |
| 522 | 먼저 rp를 ap+bp 값으로 저장합니다. | |
| 523 | {{{#!if this.rp=ap+bp | |
| 524 | }}}{{{#!if ap+bp >18 | |
| 525 | 인덱스 i를 빌려와 소수점 아래 자릿수를 잡고 계산하는 과정에서 쓸 것입니다. | |
| 526 | {{{#!if i=ap+bp-18 | |
| 527 | }}}}}} | |
| 528 | ap+bp 값이 18 이하일 경우 그 값을 i로 둡니다. | |
| 529 | {{{#!if ap+bp<=18 | |
| 530 | {{{#!if i=ap+bp | |
| 531 | }}}}}}}}} | |
| 532 | ||
| 533 | 519 | 18자리씩 곱셈계산을 할 수 있도록 입력했던 a와 b의 문자열을 확장할 것입니다. |
| 534 | 520 | a와 b 각각 소수점 윗자리와 소수점 아래자리의 문자열의 빈 공간을 0으로 채워 18자로 만듭니다. |
| 535 | 521 | 소수점 윗자리는 왼쪽에서 0을 채워나갑니다. |
| ... | ... | |
| 690 | 676 | {{{#!if bb=bb+"0" |
| 691 | 677 | }}}}}} |
| 692 | 678 | |
| 679 | 변수 tw를 가져옵니다. (tv는 1로 초기화 된 채로 있습니다.) | |
| 680 | 소수점 아래 18자리의 아래인 제19~36번 자리를 ri로 둡니다. | |
| 681 | ri에서 자릿수가 넘치면 넘친 만큼을 rb로 넘기고, rb에서 자릿수가 넘치면 넘친 만큼을 ru로 넘깁니다. ru에서 자릿수가 넘치면 rs로 넘깁니다. | |
| 682 | {{{#!if tw=(+ab.substr(0,18))*(+bb.substr(17,1)), tw="@tw@" | |
| 693 | 683 | }}} |
| 684 | ||
| 685 | ||
| 686 | ||
| 687 | 여기까지가 a*b 계산과정입니다. | |
| 694 | 688 | }}} |
| 695 | 689 | |
| 690 | ##곱셈 문자열 정리 | |
| 691 | ||
| 692 | }}} | |
| 693 | ||
| 696 | 694 | error code 03 번 : 오버플로 |
| 697 | 695 | error code 04 번 : 언더플로 |
| 698 | 696 | error code 05 번 : 0으로 나눌 수 없습니다. |
| ... | ... |