| r214 vs r215 | ||
|---|---|---|
| ... | ... | |
| 10 | 10 | '''au''' : --gold-- "a" upper value (string→integer); '''bu''' : "b" upper value (string→integer); |
| 11 | 11 | '''ab''' : "a" below value (string→integer); '''bb''' : "b" below value (string→integer); |
| 12 | 12 | '''ap''' : "a" # of places of decimal (for addition or subtraction); |
| 13 | '''ac''' : | |
| 13 | '''ac''' : a '''c'''onstant of a for division (integer); | |
| 14 | 14 | '''bp''' : "b" # of places of decimal (for addition or subtraction); |
| 15 | '''bc''' : | |
| 15 | '''bc''' : a '''c'''onstant of b for division (integer); | |
| 16 | 16 | 0.303과 0.0303은 다른 수이므로 자리수가 다름을 표시할 용도 |
| 17 | 17 | '''ru''' : "result" upper value (integer→string); '''rb''' : "result" below value (integer→string); |
| 18 | 18 | '''rp''' : "result" # of places of decimal (integer); |
| ... | ... | |
| 303 | 303 | {{{#!if bu=bu.substr(1,bd-1) |
| 304 | 304 | }}}}}} |
| 305 | 305 | |
| 306 | 그 다음 --앞자리에 0만 여러 개 적어놓고 장난치는 사람이 있을까봐-- au를 값으로 바꾼 다음 다시 문자열로 변환하여 앞자리에 있는 0들을 모두 삭제합니다. bu도 그렇게 둡니다. | |
| 307 | {{{#!if au=+au, au=au.toString(), bu=+bu, bu=bu.toString() | |
| 308 | }}} | |
| 309 | ||
| 306 | 310 | a 또는 b값이 0이 되려면 au, ab 둘 다 0이 되거나 bu, bb 둘 다 0이 되어야 합니다. a 또는 b 값이 0일 경우 당연히 음수 부호가 표시되지 않습니다. |
| 307 | 311 | {{{#!if ((+au==0)&&(+ab==0))||((+bu==0)&&(+bb==0)) |
| 308 | 312 | 곱셈에서 0을 곱하면 0이 되므로, 곱셈의 경우 a 또는 b가 0이 될 때 계산 결과에 0을 반환합니다. |
| ... | ... | |
| 344 | 348 | {{{#!if au = "000000000000000000" + au |
| 345 | 349 | +18자}}}{{{#!if au=au.substr(au.length-18,18) |
| 346 | 350 | }}} |
| 347 | ||
| 348 | 351 | {{{#!if bu = "000000000000000000" + bu |
| 349 | 352 | +18자}}}{{{#!if bu=bu.substr(bu.length-18,18) |
| 350 | 353 | }}} |
| ... | ... | |
| 353 | 356 | {{{#!if ab += "000000000000000000" |
| 354 | 357 | +18자}}}{{{#!if ab=ab.substr(0,18) |
| 355 | 358 | }}} |
| 356 | ||
| 357 | 359 | {{{#!if bb += "000000000000000000" |
| 358 | 360 | +18자}}}{{{#!if bb=bb.substr(0,18) |
| 359 | 361 | }}}}}} |
| 360 | 362 | |
| 361 | 363 | {{{#!if f=="/" |
| 362 | 364 | 나눗셈은 소수점 위 18번째 자리부터 내려가면서 처음으로 0이 아닌 숫자가 있으면 그 숫자가 처음 숫자가 되도록 숫자를 왼쪽으로 밀어두려고 합니다. 그 다음 오른쪽을 0으로 채웁니다. |
| 363 | ||
| 364 | {{{#!if | |
| 365 | au를 왼쪽으로 밀 경우 남게 되는 자릿수를 변수 tu로 둡니다. (후술할 아래 곱셈연산과 겹치지 않습니다.) | |
| 366 | {{{#!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) | |
| 365 | 367 | }}} |
| 366 | ||
| 367 | {{{#!if t | |
| 368 | {{{#!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) | |
| 368 | 369 | }}} |
| 369 | 370 | }}} |
| 370 | 371 | }}} |
| ... | ... |