BCD Division « Next Oldest | Next Newest »

 ▼ Mike >t Junior Member Posts: 1 Threads: 1 Joined: Jan 1970 04-08-2005, 06:48 PM One time 'quiche eater' seeks a (clear) description of the algorithm to perform the division of two (unpacked) BCD numbers (10 digit mantessa + 2 digit exponent - now where might you have seen that format before).I know it is shift and subtract but I can't remember exactly how it was supposed to work - I do remember it wasn't obvious!Mike T.PS I don't want to use an existing library like BIGINT or similar. ▼ John Limpert Member Posts: 172 Threads: 13 Joined: Jul 2005 04-08-2005, 07:13 PM I'd start at http://www2.hursley.ibm.com/decimal. The web page's author is the expert on decimal arithmetic. ▼ Mike T. Senior Member Posts: 282 Threads: 46 Joined: Jul 2005 04-09-2005, 04:37 PM Many thanks, I'd had found the site earlier but not that page - must have missed it. I'll have to read it slowly to make sense of it properly (and I guess I'll have to create my own flowchart or structure diagram as there wasn't one) but I think that given a few days, and no too many late nights I should be able to cut some useful code...Mike T. hugh steers Senior Member Posts: 536 Threads: 56 Joined: Jul 2005 04-11-2005, 07:31 PM to perform U/V where these are bcd floats. first unpack the mantissas, exponents and signs so that you have two positive mantissas u/v. start by settings the exponent of the result, w, to be exp(U) - exp(V). now perform the u/v division as follows: ```(1) ensure that u >= v. if not, shift u left 1 packed bcd digit and decrement w, if quotient = 0, otherwise shift quotient left 1 digit.. goto (1) (2) while u >= v, perform u = u - v. count the number of subtractions, q. this is the next digit of the answer. goto (1) ``` there’s a bit more to it than this but essentially you are shifting until you’ve got something to subtract then you subtract all you can at each digit and put the number of subtractions into the answer and continue until you’ve got a full house of quotient mantissa. lastly fix up the signs and exponent of the quotient. i wrote some `C’ code one for this here: http://www.voidware.com/bcdfloats.htm ▼ Mike T. Senior Member Posts: 282 Threads: 46 Joined: Jul 2005 04-12-2005, 06:33 PM Now I can make a connection - I did find your web site a while ago, and I should have guessed you would be reading these posts! Unfortunately I haven't yet got the hang of unravelling somebody else's code and have been having more than a little difficulty sorting out what was going on as your routines use packed BCD which makes life a little more interesting. Thank you for the precis. Mike T. ▼ hugh steers Senior Member Posts: 536 Threads: 56 Joined: Jul 2005 04-13-2005, 12:04 PM those routines are a bit old. i have a new 20 digit bcd library now. i keep meaning to put this up for download.

 Possibly Related Threads... Thread Author Replies Views Last Post HP Prime polynomial long division bluesun08 13 2,599 10-30-2013, 03:29 AM Last Post: parisse Why does PEMDAS do multiplication and division before addition and subtraction? Don Shepherd 12 2,122 07-31-2013, 10:59 AM Last Post: robert rozee BCD, Binary, ...Binary Coded Duodecimal? mpi 7 1,496 02-20-2013, 04:28 PM Last Post: Paul Dale Understanding HP-16C integer division Jimi 18 3,606 10-16-2012, 09:13 PM Last Post: Eddie W. Shore HP-97S with a bad BCD interface: help me! Ignazio Cara (Italy) 3 1,084 03-22-2011, 03:54 AM Last Post: Katie Wasserman Corvallis Division - DIV.39 Joerg Woerner 3 1,127 09-13-2010, 04:15 PM Last Post: Martin Pinckney HP 48gII displays division as a fraction Peter Klein 5 1,371 04-10-2010, 05:32 PM Last Post: Peter Klein Math Software that supports BCD? Tim Wessman 16 3,023 04-07-2010, 06:53 AM Last Post: Bill (Smithville, NJ) Integer division on HP 33S Antonio Maschio (Italy) 22 3,312 08-22-2006, 11:47 AM Last Post: e,young exponents in 14-nybble BCD floating-point representations Cameron Paine 3 1,010 04-12-2006, 09:53 PM Last Post: Vieira, L. C. (Brazil)

Forum Jump: