[주의!] 문서의 이전 버전(에 수정)을 보고 있습니다. 최신 버전으로 이동
→ 원본에 대한 자세한 내용은 틀:구 계산기2 문서를 참고하십시오.
→ 떼어낸 계산기에 대한 자세한 내용은 틀:계산기/구버전 문서를 참고하십시오.
as : "a" value to string; bs : "b" value to string;
al : "a" string length (integer); bl : "b" string length (integer)
ad : "a" decimal point (integer); bd : "b" decimal point (integer);
au :
ab : "a" below value (string→integer); bb : "b" below value (string→integer);
ap : "a" # of places of decimal (for addition or subtraction);
ac : a constant of "a" for division (integer);
bp : "b" # of places of decimal (for addition or subtraction);
bc : a constant of "b" for division (integer);
0.303과 0.0303은 다른 수이므로 자리수가 다름을 표시할 용도
ru : "result" upper value (integer→string); rb : "result" below value (integer→string);
rp : "result" # of places of decimal (integer);
rs : "result" suprerior value (integer→string); ri : "result" inferior value (integer→string);
i : index;
tu : temporary value 1 (integer); tv : temporary value 2 (integer);
tw : temporary value 3 (integer); tx : temporary value 4 (integer→string);
ty : temporary value 5 (integer); tz : temporary value 6 (integer);
pd : padding with zeros. (string)
ps : pass (logical); ts :
ea : error code about "a" (integer); eb : error code about "b" (integer);
wa : warning code about "a" (integer); wb : warning code about "b" (integer);
ma : message about "a" (string); mb : message about "b" (string);
tm : temporary string, or transaction message (string); tn : temporary string 2 (string);
ns : negative sign for multiplication and division (string);
값을 미리 정의하여 초기화합니다. 중간에
소수점이 발견되는 자리 번호가 ad이므로 ad+1번에 해당되는 자리부터 끝까지 표기합니다.
the seed에서 지원되는 long(integer)가 unsigned였으면 1844경까지 가서 충분히 19자리로 놀 수 있었는데, signed long이므로 922경까지 가능한 공간에서 18자리로 잘라내기를 합니다. (소수점 위 최대 18자리, 소수점 아래 최대 18자리)
(반점(,)을 자동적으로 생략하고 들어가는 것은 나중에 생각하겠습니다.)
유효성 검사가 종료되었으면 ts와 br를 false로 초기화합니다 유효성 검사에 쓰인 tm과 tn 값을 빈 문자열 값으로 초기화합니다.
입력한 소수점 아래에 입력한 값을 정리합니다. 이에 따라 ap, bp값도 다시 조정됩니다.
그 다음
이 상태의 au를 ma로 저장하고 ab가 빈 문자열이 아니라면 ab도 ma에 저장합니다. 같은 방법으로 bu, bb을 mb에 저장합니다.
a가 소수점 윗부분이 0이 되는 음수인 경우 "-0"으로 저장된 문자열은 정수값으로 바꿀 때 0이 되므로 ma앞에 -를 붙입니다.
덧셈과 뺄셈 계산과정을 적어봅니다.
a와 b 모두 0이 아닌 경우에서 곱셈을 연산하는 과정입니다.
a와 b 모두 0이 아닌 경우에서 나눗셈을 연산하는 과정입니다.
연산이 끝났으면 표기된 숫자를 정리합니다.
먼저 ru를 (곱셈연산에서 정수값으로 나올 수 있고, 나눗셈에서 몫이 1보다 작은 값이 나오는 경우같이 값을 부여하지 않았다면 초기화할 때 정의했던 정수 0인 채로 있으므로) 문자열로 바꿉니다.
18자리씩 끊어 표기하므로 소수점 위 19~36번째 자리에 해당하는 rs값이 (가령 곱셈에서, 곱한 값을 더한 결과가) 0일 경우 rs를 빈 문자열로 바꿉니다. 이 때 ru를 정수로 바꿔 ru 왼쪽에 있는 0들을 지운 다음, ru를 문자열로 바꿉니다.
계산과정에서 ru의 윗자리인 rs값이 0보다 클 경우, 1~18번째 자리인 ru에 빈 자리를 채우도록 ru의 왼쪽을 0으로 채웁니다.
i보다 소수점 아래부분을 더 써내려가야 하는 상황이 아닌(나눗셈에서 ts가 false인) 경우에서, 소수점 아래 19~36번째 자리에 해당하는 ri값이 0일 경우 ri를 빈 문자열로 바꿉니다.
이 때 ri와 rb가 모두 0일 경우 rb도 빈 문자열로 바꾸고 rp=0으로 둡니다.
ri가 빈 문자열이 아닐 (+ri가 0보다 클) 때 true를 주는 논리값으로 ps를 정의합니다.
!ts인 상황에서 ps가 true이면 rp를 ri의 길이로, 그렇지 않고 rb만 0이 아닌경우 rp를 rb의 길이로 정의합니다.
!ts이면서 ri가 빈 문자열이 아닐 경우 ri의 오른쪽부터 붙은 "0"들을 모두 지웁니다.
!ts이면서 이면서 ri가 빈 문자열일 경우, rb의 오른쪽에 붙은 "0"들을 모두 지웁니다,
ts인 경우 rb, ri의 오른쪽 부분을 정리하지 않고 rp를 39로 정의합니다.
rb 정리를 이것으로 종료합니다.
error
1 : 오버플로
5 : 이중 소수점 표기
6 : 소수점 윗부분 오류
7 : 소수점 아랫부분 오류
warning
1 : 소수점 아래 입력한 자릿수가 너무 많음.
sa : searching a; sb : searching b; sf : searching f;
rl : result string length to output; p : a point of string(s); ps : pass
ad : "a" decimal point of string variable 'ma' (integer);
bd : "b" decimal point of string variable 'mb' (integer);
md : displaying mode number (string→integer); ms : message for correction (string)
tm : temporary string, or transaction message (string); tn : temporary string 2 (string);
tx : temporary value 1 (integer); ty : temporary value 2 (integer); tz : temporary value 3 (integer);
comment : comment (string, unused);
ru는 계산결과에서 소수점 위 자리이므로, dot(.)이 나오지 않습니다.
변수 a와 변수 b, 그리고 연산자 f를 입력하세요...