Kristian Nielsen wrote:
Arjen Lentz <[email protected]> writes:

Hi Konstantin,

On 08/02/2009, at 6:48 PM, Konstantin Osipov wrote:
* Jim Starkey <[email protected]> [09/01/16 08:01]:
A more intelligent, denser, faster, and more intuitive format would
use
a single vector of binary words.  On a challenge from Monty (W.), I
did
a relative performance measure between the Falcon decimal type and
the
"server" type.  The worst case (> 18 decimal digits of precision)
showed
Falcon 40% faster.  For anything less than 18 decimal digits of
precision, Falcon was approximately infinitely faster (Falcon uses
a 64
bit int with a decimal scale factor).
There is no precise conversion from base 2/4/8/16 representation to
base
5/10 representation when you have digits after the (decimal, binary)
point.

That's why base 2 representation just can't be used.
Can you give an example of this?

Konstantin's point is that there are fractional numbers that have an exact
representation in decimal, but no exact representation as a (finite) binary
fraction. Like the number 0.1 for example. Just like 1/3 = 0.3333333...
has no exact finite representation in decimal.

But Jim wrote that

    "Falcon uses a 64 bit int with a decimal scale factor"

So I assume this means that falcon actually stores numbers in a kind of base
10**18 representation, as two parts. One would be an unlimited precision
integer, with each group of 18 decimal digits stored in base-2 as a 64-bit int
(64 bits will hold just over 19 decimal digits). The other would be the
position of the decimal point. So 12.3456 would be stored as (123456, 4).

So this would store finite decimal fractions exactly, but it is not really
base 2/4/8/16, just the individual digits are.

Probably a look at the Falcon source would provide more information.


In general, you are correct. In fact, however, Falcon treats all numeric values < 2**63 as binary numbers of size 16, 32, or 64 bits as scaled binary. Most, however, have a scale of zero. When fetching a number from a Value object, for example, the caller gives the desired scale factor (defaults to zero). The cost of checking for equal scales costs about nothing in a centralized Value object. If you had to do it in a thousand places, it would drive you nuts.


_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to