[fpc-devel] divide bcd's

LacaK lacak at zoznam.sk
Fri Jun 17 12:05:06 CEST 2011


Hi Joost,
for me:

100/1=10 <--error
10/1=10
100/10=10
1000/1=10 <--error
1000/10=10 <--error
1000/100=10
100/2=50
1007/5=201.4

-Laco.

> Hi all,
>
> Dividing BCD's doesn't go wel:
>
> 100/1=10
> 100/2=overflow
> 1007/5=overflow
>
> It's all in this function in the FmtBCD unit:
>
> procedure BCDDivide ( const Dividend,
>                               Divisor : tBCD;
>                           var BCDout : tBCD );
>
> I've tried to understand how the code works. I think it tries to
> implement the algorithm as described here: 
> http://media.digikey.com/PDF/Reference%20Design/Digi-Key%20DDS%20group/DKAN0003A_BCD_Division.pdf
>
> But I can't follow. Florian checked in the original code. Did he wrote
> it himself? It could be that there's just a small problem with an index
> or something. But I can't find it. Maybe someone else can.
>
> If not, I think we should rewrite the whole function.
>
> Joost.
>   




More information about the fpc-devel mailing list