can somebody help me to know a vert efficient algorithm in dividing more than 32 bytes of number?

e.g.
65534.99/2326.84=28.1648029
=>6553499/232684 =281648029
=>63 FF 9B/03 8C EC=10 C9 9B 9D
how could that be?

my algo is that use shifts and subs but in a bitwise manner
i want to divide byte by byte and not bit by bit

32 byte dividend is enormous.. out of curiousity why do you have to divide such a precised or huge number? Secondly, what is exactly efficent, the code algorithm in size or how fast can you produce the results? Also, how big should we expect the divisor to be? And lastly which architecture are we looking at here, there would be limitations depending on the what processor we are dealing with.

From your examples, I don't quite understand, really I see a floating point translated to fixed point then to heximals, nothing out of the ordinary if you only require 2 decimal places.

hi try this one..


.model SMALL
.386
.DATA
a1 dB 'Enter the first number$'
a2 dB 'Enter the second number$'
A3 DD ?
A4 DD ?
.code
.STARTUP
mov ebx,00000000H
mov edx,00000000H
mov eax,00000000H
mov cl,4

mov dx,offset a1
mov ah,09h
int 21h
MOV EDX,00000000H
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar1
sub al,07
ar1:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar2
sub al,07
ar2:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar3
sub al,07
ar3:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar4
sub al,07
ar4:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar5
sub al,07
ar5:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar6
sub al,07
ar6:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar7
sub al,07
ar7:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar8
sub al,07
ar8:add bl,al
mov a3,ebx
mov ebx,00000000H
mov dx,offset a2
mov ah,09h
int 21h
MOV EDX,00000000H
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at1
sub al,07
at1:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at2
sub al,07
at2:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at3
sub al,07
at3:add bl,al
shl ebx,cl

mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at4
sub al,07
at4:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at5
sub al,07
at5:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at6
sub al,07
at6:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at7
sub al,07
at7:add bl,al
shl ebx,cl

mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at8
sub al,07
at8:add bl,al

mov edx,00000000H
mov eax,a3
div ebx
mov a4,eax
mov edx,00000000h
mov edx,A4
and edx,0f0000000h
mov cl,28
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad1
add edx,07h
ad1:mov ah,02
int 21h

mov edx,A4
and edx,0f000000h
mov cl,24
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad2
add edx,07h
ad2:mov ah,02
int 21h

mov edx,A4
and edx,00f00000h
mov cl,20
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad3
add edx,07h
ad3:mov ah,02
int 21h

mov edx,A4
and edx,000f0000h
mov cl,16
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad4
add edx,07h
ad4:mov ah,02
int 21h

mov edx,A4
and edx,0000f000h
mov cl,12
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad5
add edx,07h
ad5:mov ah,02
int 21h

mov edx,A4
and edx,00000f00h
mov cl,08
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad6
add edx,07h
ad6:mov ah,02
int 21h

mov edx,A4
and edx,000000f0h
mov cl,04
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad7
add edx,07h
ad7:mov ah,02
int 21h

mov edx,A4
and edx,0000000fh
mov cl,00
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad8
add edx,07h
ad8:mov ah,02
int 21h
.exit
end

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.