View Single Post
Old 08 September 2020, 16:07   #8
Thomas Richter
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 1,149
Originally Posted by JoeJoe View Post
I am currently working on the display and calculation of scores. I have already read the thread "BCD Arithmetic - howto^". The simple adding and subtracting is no problem. But I have to divide the score by 50. Also the points can be increased by graduation 3*90 or 5*240 etc.
Now to my problem. For dividing and multiplying with BCD there are no 1:1 commands. Multiplying can be avoided by using LookUp tables and adding. But for x:50 there is no alternative.

:50 is simple enough (already answered by others), but general multiplication or division in BCD is slow, in general. To multply, use the pen-and-paper algorithm of multiplying digit by digit, then add the partial products by a BCD add. Similarly, a BCD division follows the pen-and-paper algorithm of continuous subtraction until an overflow, and keeping the number of times a number was subtracted, then carry over the remainder, and continue with the next digit.

All these algorithms are slow...
Thomas Richter is offline  
Page generated in 0.04543 seconds with 11 queries