Re: Fw: BCD-lib
- Posted by Kat <gertie at PELL.NET> Apr 14, 2002
- 412 views
On 14 Apr 2002, at 9:36, petelomax at blueyonder.co.uk wrote: > > On Sat, 13 Apr 2002 21:15:59 -0500, Kat <gertie at PELL.NET> wrote: > > > The question is how will > >Eu store the BCD bytes for us? > > Off the top of my head, a "short" BCD could be held in an integer, > which is 31 bits. The natural scheme would be sign+ 7 nibbles > (therefore seven significant digits), using 29 bits, leaving space for > a 2-bit mantissa (therefore between 0 and 3 decimal places). That > could accurately hold 0.001 or 9,999,999. The largest money value it > could hold would be 99,999.99. Longer BCD values could be held as a > sequence of n integers, with up to 7*n significant digits and 3*n > decimal places. > > Alternatively, you explicitly specify how many decimal places you need > at the start of the program and the routines return the shortest > possible sequence which will hold the calculated result. I prefer this, rather than locking the user to a limited number of digits on either side of decimal. If someone really needs to measure the distance to Alpha Centuri in angstroms, i'd let them. What i was worried about was that every nibble would take a 32bit integer in Eu, making a large data store in memory impossible, like with storing strings in sequences now. Kat