| r215 vs r216 | ||
|---|---|---|
| ... | ... | |
| 3 | 3 | {{{#!if a= ,b= ,f= |
| 4 | 4 | }}} |
| 5 | 5 | {{{#!wiki style="display: none; display: inline;" |
| 6 | ##초기화 | |
| 6 | ##== 초기화 == | |
| 7 | 7 | '''as''' : "a" value to string; '''bs''' : "b" value to string; |
| 8 | 8 | '''al''' : "a" string length (integer); '''bl''' : "b" string length (integer) |
| 9 | 9 | '''ad''' : "a" decimal point (integer); '''bd''' : "b" decimal point (integer); |
| 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''' : a '''c'''onstant of a for division (integer); | |
| 13 | '''ac''' : a '''c'''onstant of "a" for division (integer); | |
| 14 | 14 | '''bp''' : "b" # of places of decimal (for addition or subtraction); |
| 15 | '''bc''' : a '''c'''onstant of b for division (integer); | |
| 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); |
| ... | ... | |
| 41 | 41 | {{{#!if this.bu=bs, bb="", bp=0+0, bd=bu.length |
| 42 | 42 | }}}}}} |
| 43 | 43 | |
| 44 | ##유효성 검사 | |
| 44 | 입력한 소수점 아래에 입력한 값을 정리합니다. 이에 따라 ap, bp값도 다시 조정됩니다. | |
| 45 | {{{#!if ap>9, ab.substr(ap-9,9)=="000000000" | |
| 46 | {{{#!if ab=ab.substr(0,rp-9), ap=ap-9 | |
| 47 | }}}}}} | |
| 48 | {{{#!if ap>4, ab.substr(ap-4,4)=="0000" | |
| 49 | {{{#!if ab=ab.substr(0,ap-4), ap=ap-4 | |
| 50 | }}}}}} | |
| 51 | {{{#!if ap>2, ab.substr(ap-2,2)=="00" | |
| 52 | {{{#!if ab=ab.substr(0,ap-2), ap=ap-2 | |
| 53 | }}}}}} | |
| 54 | {{{#!if ap>2, ab.substr(ap-2,2)=="00" | |
| 55 | {{{#!if ab=ab.substr(0,ap-2), ap=ap-2 | |
| 56 | }}}}}} | |
| 57 | {{{#!if ap>1, ab.substr(ap-1,1)=="0" | |
| 58 | {{{#!if ab=ab.substr(0,ap-1), ap=ap-1 | |
| 59 | }}}}}} | |
| 60 | {{{#!if bp>9, bb.substr(bp-9,9)=="000000000" | |
| 61 | {{{#!if bb=bb.substr(0,rp-9), bp=bp-9 | |
| 62 | }}}}}} | |
| 63 | {{{#!if bp>4, bb.substr(bp-4,4)=="0000" | |
| 64 | {{{#!if bb=bb.substr(0,bp-4), bp=bp-4 | |
| 65 | }}}}}} | |
| 66 | {{{#!if bp>2, bb.substr(bp-2,2)=="00" | |
| 67 | {{{#!if bb=bb.substr(0,bp-2), bp=bp-2 | |
| 68 | }}}}}} | |
| 69 | {{{#!if bp>2, bb.substr(bp-2,2)=="00" | |
| 70 | {{{#!if bb=bb.substr(0,bp-2), bp=bp-2 | |
| 71 | }}}}}} | |
| 72 | {{{#!if bp>1, bb.substr(bp-1,1)=="0" | |
| 73 | {{{#!if bb=bb.substr(0,bp-1), bp=bp-1 | |
| 74 | }}}}}} | |
| 75 | ||
| 76 | ##== 유효성 검사 == | |
| 45 | 77 | the seed에서 지원되는 long(integer)가 unsigned였으면 1844경까지 가서 충분히 19자리로 놀 수 있었는데, signed long이므로 922경까지 가능한 공간에서 18자리로 잘라내기. 소수점 위 최대 18자리, 소수점 아래 최대 18자리 |
| 46 | 78 | {{{#!if ((au[0]!=45)&&(au.length>=19))||((au[0]==45)&&(au.length>=20)) |
| 47 | 79 | error code of a 01번 : 오버플로 |
| ... | ... | |
| 61 | 93 | {{{#!if wb=1, bb=bb.substr(0,18), bp=18 |
| 62 | 94 | }}}}}} |
| 63 | 95 | |
| 64 | ||
| 96 | (반점(,)을 자동적으로 생략하고 들어가는 것은 나중에 생각하겠습니다.) | |
| 65 | 97 | {{{#!if false |
| 66 | 98 | ps와 test 변수를 이용합니다. |
| 67 | 99 | {{{#!if test=((a!=null)||(a!="")), break=false |
| ... | ... | |
| 94 | 126 | |
| 95 | 127 | error code 03 번 : 0으로 나눌 수 없습니다.(아래쪽 참고) |
| 96 | 128 | |
| 129 | ||
| 130 | ##== 덧셈, 뺄셈 == | |
| 97 | 131 | 덧셈과 뺄셈 계산과정을 적어봅니다. |
| 98 | 132 | {{{#!if (f=="+")||(f=="-") |
| 99 | 133 | |
| ... | ... | |
| 307 | 341 | {{{#!if au=+au, au=au.toString(), bu=+bu, bu=bu.toString() |
| 308 | 342 | }}} |
| 309 | 343 | |
| 344 | ||
| 310 | 345 | a 또는 b값이 0이 되려면 au, ab 둘 다 0이 되거나 bu, bb 둘 다 0이 되어야 합니다. a 또는 b 값이 0일 경우 당연히 음수 부호가 표시되지 않습니다. |
| 311 | 346 | {{{#!if ((+au==0)&&(+ab==0))||((+bu==0)&&(+bb==0)) |
| 312 | 347 | 곱셈에서 0을 곱하면 0이 되므로, 곱셈의 경우 a 또는 b가 0이 될 때 계산 결과에 0을 반환합니다. |
| ... | ... | |
| 327 | 362 | 곱셈과 나눗셈에서 a와 b 모두 0이 아닌 경우를 봅니다. |
| 328 | 363 | {{{#!if ((+au!=0)||(+ab!=0))&&((+bu!=0)||(+bb!=0)) |
| 329 | 364 | |
| 330 | 나눗셈 자리를 계산할 목적으로 ac, bc 값을 (상용로그 값으로서) 계산할 숫자의 자릿수로 다시 정의합니다. | |
| 331 | {{{#!if +bu==0 | |
| 332 | {{{#!if bc=-bp | |
| 333 | }}}}}}{{{#!if +bu!=0 | |
| 334 | {{{#!if bc=+bu.length | |
| 335 | }}}}}} | |
| 336 | ||
| 337 | {{{#!if +au!=0 | |
| 338 | {{{#!if ac=-ap | |
| 339 | }}}}}}{{{#!if au==0 | |
| 340 | {{{#!if ac=+au.length | |
| 341 | }}}}}} | |
| 342 | ||
| 343 | 365 | {{{#!if f=="*" |
| 344 | 366 | 곱셈계산에서 18자리씩 곱셈을 할 수 있도록 입력했던 a와 b의 문자열을 확장할 것입니다. |
| 345 | 367 | |
| ... | ... | |
| 367 | 389 | }}} |
| 368 | 390 | {{{#!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) |
| 369 | 391 | }}} |
| 392 | ||
| 370 | 393 | }}} |
| 371 | 394 | }}} |
| 372 | 395 | 여기까지 곱셈 또는 나눗셈에서 숫자를 초기화하는 과정입니다. |
| ... | ... |