Re: [SLUG] Numeric Storage Format

From: Paul M Foster (paulf@quillandmouse.com)
Date: Fri Dec 29 2006 - 16:07:08 EST


Ian C. Blenke wrote:
> Paul M Foster wrote:
>
>> 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.
>
>
> Right. Like I said, you already understand BCD isn't what we're talking
> about here.
>
> You realize that 0x39 (hex) is 57 (decimal), right? or 00111001 binary.
> It's a binary integer. Pure and simple.
>
>> 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. I haven't been able to find any *good*
>> arbitrary precision library for PHP, so I'm working or porting or
>> adapting this C library to PHP.
>>
>> So anyway, what do you call this storage format?
>
>
> I call it an integer. Just a plain, raw binary integer. 8 bits contain
> an integer value between 0 and 99. The high-bit remains unused (as 128
> is never reached). Don't know how else to explain this to you.
>
> unsigned short int number;
> number=57;
>
> Assuming that a "short int" is an 8 bit value for your
> architecture/platform/compiler.
>
> If integer isn't adequate to explain a storage format to you, what do
> you want to see?
>
> |Byte|
> |8 Bits/Byte: 8 Significant Binary Digits: 76543210|
> |%00111001|
> |0x39|
> |57|
>
> Just trying to understand what you're trying to tell me here.
>

Yes, of course it's a short int. But when you're storing a number this
way, you store it as an array of bytes, each capable of expressing a
number 0-99. Thus, you can store numbers of arbitrary precision, since
your array can be as large as you need.

I just figured there must be some special name for storing things this
way. Normally an integer for a 32 bit platform would be stored as a
binary value between 0 and 2^31. Or BCD would be stored with a digit per
nibble. This was a unique way of storing the data, so I figured there
must be some name for it. Guess not.

Paul

-- 
Paul M. Foster
-----------------------------------------------------------------------
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:16:33 EDT