Patrick Earl wrote:
> On Sat, Mar 26, 2011 at 10:03 PM, Darren Duncan <dar...@darrenduncan.net> 
> wrote:
>> You could store your exact precision numbers as a pair of integers 
>> representing
>> a numerator/denominator ratio and then have math operators that work on these
>> pairs like they were one number.  You would then know at the end how to move 
>> the
>> radix point since that was kept track of along with the number. -- Darren 
>> Duncan
> 
> If you did this, you wouldn't be able to compare numbers in the
> database without resorting to division.

Sure you can.  You make sure the two operands have the same denominator and 
then 
compare the numerators.  Or you resort to multiplication, as they taught in 
grade school (dividing by a fraction is the same as multiplying by its 
inverse). 
  Everything is just integers.

If your normal operations are just straight-up addition/subtraction and 
multiplication and all your operands have the same radix (are in base 10), then 
your results are all guaranteed to be in base-10 as well, since any 
denominators 
in results would be positive powers of 10.  Likewise if you're doing division 
but you ensure that any divisor is a power of 10.

> If you just specified how
> many fixed decimal places there were, you could zero-pad strings if
> you only needed to perform comparison operations.  Obviously you'd
> need to create custom operations, as you suggest, for other math
> operators.

We should be able to avoid strings with this entirely.

> If SQLite can't decide on a base-10 format itself, perhaps the answer
> lies in enhancing the API to allow for custom type storage and
> operators.

-- Darren Duncan
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to