On Fri, 29 Dec 2006, Paul M Foster wrote:
> Ian C. Blenke wrote:
>> Eben King wrote:
>>> So in memory it'd be '5' '7' NUL = 0x35 0x37 0x00, right?
>>
>> The source ASCII string, nstr, is "57", which would be 0x35 0x37 0x00 as
>> a null terminated string, correct.
>>
>>>> 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.
>>> I'd call it "stored as an ASCII string" m'self, but ICBW.
>>
>> I think he is saying that he is converting from an ASCII string to this
>> format. The format is a binary representation of the number, by
>> subtracting the value of an ASCII "0", ie:
[snip]
>> ie, an integer representation of the string.
>>
>> The question boils down to how to handle negative numbers: one's
>> complement or two's complement. I'll wager that it is the latter.
>
> No no no. BCD stores one digit per nibble. The "digits" here aren't stored as
> digits. Each byte contains a binary number from 0-99. The example above,
> expressed as hexadecimal, would be stored as 0x39.
So if you're going to store number N, it gets converted to hex and then
stored, one digit per nybble? Wait, what did you say happens to >2 digit
numbers?
> Forget signs. The library uses a C structure to store numbers. The exponent
> and sign are stored as separate fields. The significant digits are what we're
> talking about here.
>
> FWIW, the link to the library in question is:
>
> http://www.tc.umn.edu/~ringx004/mapm-main.html
>
> I'm having to do price lists and payroll in PHP, and the math inaccuracies
> are killing me.
You are/were using integer math, not floating point, right? Fixed point is
even better, but harder to work with.
-- The powers in charge keep us in a continuous stampede of patriotic fervor with the cry of national emergency. Always there has been some terrible evil to gobble us up if we did not furnish the sums demanded. Yet these disasters seem never to have been quite real. -- D. MacArthur ----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:15:28 EDT