[fpc-devel] divide bcd's

Joost van der Sluis joost at cnoc.nl
Tue Jun 14 09:28:40 CEST 2011


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.
-- 
My Lazarus blog: http://www.lazarussupport.com/lazarus/weblog




More information about the fpc-devel mailing list