|
[求助]e=2.7..............,是什么意思?怎么来的?
e的计算比p要简单得多。
下面是我以前写的一个计算e的程序:
rogram to compute e
;Jason Chen
;Aug 16,1992
;
;Email : jason@szonline.net
;Homepage : http://www.jason314.com
N equ 505 ;位数/4+5
DATA SEGMENT
k dd 1
divisor dw 3
DATA ENDS
STK SEGMENT PARA STACK
dw 200h dup(?)
STK ENDS
CODE SEGMENT
.386
ASSUME CS:CODE,FSATA,SS:STK
start: mov ax,DATA
mov fs,ax
mov bx,cs
mov ax,ds
sub bx,ax
mov ax,offset end_prog
shr ax,4
add bx,ax
inc bx
mov ah,4ah
int 21h
mov bx,(N+1)/8+1 ;(N+1)*2/16+1
mov ah,48h
int 21h
jnc ds_ok
jmp exit
ds_ok: mov ds,ax
mov bx,(N+1)/4+1 ;(N+1)*4/16+1
mov ah,48h
int 21h
jnc es_ok
jmp exit
es_ok: mov es,ax
mov word ptr ds:[2],5000
mov dword ptr es:[4],5000
mov esi,2
xor eax,eax
loop_clear: mov [esi+esi],ax
mov es:[esi*4],eax
inc esi
cmp esi,N
jbe loop_clear
mov cx,10000
loop1: xor dx,dx ;clear remainder
mov bx,divisor
mov esi,fs:k ;si is loop var
loop_compute:
mov ax,dx ;remainder==>ax
mul cx
add ax,[esi+esi]
adc dx,0
div bx
add es:[esi*4],eax ;quotient
mov [esi+esi],ax
inc esi
cmp esi,N
jbe loop_compute
mov esi,fs:k
loop_search:
cmp word ptr [esi+esi],0
je next
mov fs:k,esi
inc fs:divisor
jmp loop1
next: inc esi
cmp esi,N
jbe loop_search
;--computation complete
mov esi,N
loop_carry: mov eax,es:[esi*4]
xor edx,edx
div ecx
mov es:[esi*4],dx ;remainder
dec esi
add es:[esi*4],eax ;quotient
cmp esi,1
jae loop_carry
mov dl,';2';
mov ah,2
int 21h
mov esi,1
loop_print: xor dx,dx
mov ax,es:[esi*4]
mov cx,1000
div cx
push dx ;save next digit
mov dl,al
call disp
;----
pop ax
xor dx,dx
mov cx,100
div cx
push dx
mov dl,al
call disp
;----
pop ax
mov cl,10
div cl
push ax
mov dl,al
call disp
;----
pop dx
mov dl,dh
call disp
;----
inc esi
cmp esi,N-5
jbe loop_print
exit: mov ah,4ch
int 21h
disp proc
mov ah,2
add dl,30h
int 21h
ret
disp endp
end_prog:
CODE ENDS
END START
|
|