![]() |
.NET database and distributed computing tools |
|
|
|
|
Examples The following examples illustrate how some specific numbers are stored in the Base/1 Number Class encoding scheme. These four simple cases cover all the possible combinations of sign on the mantissa and sign on the exponent, i.e. positive and negative numbers, fractions and whole numbers. |
In performing the encoding, the first step always is to canonicalize the number into an equivalent form that has a mantissa with a single non-zero digit the the left of the decimal point. Digits are then processed in a pair-wise fashion to pack them into each byte, with the addition of a single trailing zero if needed to fill the last byte. Sign reversals are performed in such a way as to guarantee the collatability of signed numbers and fractions. Finally, a bias of plus or minus 10 adjusts the byte values to assure that a null byte can never occur in either the exponent or the mantissa. |
Note that this is a variable-length representation allowing numbers to be manipulated as raw null-terminated character strings, which are supported very efficiently in C++. As the precision (length) of numbers is increased, the fixed overhead of the sign, exponent, and terminator bytes diminishes in importance, and the size approaches 2 decimal digits per byte. | Also note the following compact special cases:
|
Collatability - for efficient
indexing and sorting The following table illustrates how Number Class values collate directly into proper numerical sequence, as conventional C signed character arrays. |
Unlike other numeric representations, the Number Class handles variable sign, precision, and scale, as well as a "Null" value with no need for conversion into a different representation for efficient sorting and indexing. Notice how the 10 sample numbers in the table collate correctly, from smallest to largest (null, -123.456, -12.3, -0.439, -0.0123, 0, 0.0123, 0.439, 1.234, and finally 123.456). |
Number Class Intro | Overview | FAQ | Representation | Algorithms | Sample Usage | Prices
|
|||||||
Home | Products | Consulting | Case Studies | Order | Contents | Contact | About Us |
|
|||||||
Copyright © 2012, Base One International Corporation |