Paul M Foster wrote:
> Some of you must know the answer to this. I'm working with an
> arbitrary precision library, and the fellow who wrote it is storing
> values in an array of characters. Within each "character" is
> essentially a binary number from 0 - 99. This is a C library, so if
> you had a number like 57 and you wanted to store it (and assuming you
> had the number as a string) you'd store it like:
>
> nstr = "57";
> ch = nstr[0] - '0';
> number = 10 * ch + nstr[1] - '0';
>
> Okay, now after all the explanation, what is this storage format
> *called*? It's not BCD, and it's not packed decimal. I'd like to know
> what it's called, so I can look up references on it.
The variable in question, "number", is a standard binary integer. An
"int". Or, as it is so small, perhaps a "tiny int" or a "short int".
Basically, an integer value stored as an 8 bit byte. How are negatives
coded? Is it one's complement (the high bit set for negative), or is it
a two's complement by inverting the bits and adding 1 (the latter is the
usual integer encoding).
With BCD/packed decimal, each decimal "digit" is encoded as a 4 bit
nibble, but you already know this.
Or am I misunderstanding what you are saying?
- Ian
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:15:21 EDT