Re: 68K/68332 Assembly/Binary Problem



kevinor@xxxxxxxxx wrote in part:
I probably should have mentioned this from the beginning;
the operation of the calculator is independant of a mode
function. It is possible to input a Binary number, input
an operator, input a Hex number, and request the answer of
the operation in Decimal directly. The specification also
indicates all numbers should be 64-bit; without mentioning
BCD. This would still leave a range of admittedly very high
integer values that can't be represented as 64-bit BCD.

It wouldn't be 64bit BCD, that'd never fit. You need 20 BCD
digits, or 80 bits.

In order to perform the Decimal conversions the best I can
come up with at the moment is to have a place-value table
of powers of ten and use indexing and addition algorithms
to compute the place-values during conversions. It will
take a large number of cycles but it's the best I can come
up with at the moment. Is this a valid approach do you think?

If you're dead-set on doing binary internally (do you really
think I/O mode conversions will be that frequent?) then the
fastest BCD conversion routine is likely to be a LUT on each
digit of each power of ten. 200 entries; avg 5 compares and
one branch for each digit. Possibly quicker if the upper 32
bits are zero and shortcutted.

A close second (possibly faster on some CPUs) is a short
power-of-ten LUT with successive subtractions.

-- Robert


.



Relevant Pages

  • Re: How to hande SAP BCD numrics in RPGLE
    ... program that connects to a remote Unix SAP server to retrieve cost ... BCD data is just like packed except that there is no sign. ... last digit is the next to last digit, ... the zero digit), you will then have the actual number. ...
    (comp.sys.ibm.as400.misc)
  • Re: how do I get more numbers past the decimal?
    ... Other common formats are 64 ... So for the multi precision arithmetic, ... BCD is no more and no less accurate on generic numbers than anything else., its virtue is its exact reproduction of decimal numbers like 12.3456. ... With BCD you generally use one byte per significant digit, so its as precise on the mantissa as the number of bytes allocated. ...
    (comp.lang.php)
  • Re: how do I get more numbers past the decimal?
    ... Other common formats are 64 ... So for the multi precision arithmetic, ... BCD is no more and no less accurate on generic numbers than anything else., its virtue is its exact reproduction of decimal numbers like 12.3456. ... With BCD you generally use one byte per significant digit, so its as precise on the mantissa as the number of bytes allocated. ...
    (comp.lang.php)
  • Re: how do I get more numbers past the decimal?
    ... Other common formats are 64 ... So for the multi precision arithmetic, ... BCD is no more and no less accurate on generic numbers than anything else., its virtue is its exact reproduction of decimal numbers like 12.3456. ... With BCD you generally use one byte per significant digit, so its as precise on the mantissa as the number of bytes allocated. ...
    (comp.lang.php)
  • Re: 68K/68332 Assembly/Binary Problem
    ... the operation of the calculator is independant of a mode ... integer values that can't be represented as 64-bit BCD. ... to compute the place-values during conversions. ... power-of-ten LUT with successive subtractions. ...
    (alt.lang.asm)