Search Postgresql Archives

Re: Native type for storing fractions (e.g 1/3)?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John D. Burger wrote:
Stephane Bortzmeyer wrote:

But he can write one in PostgreSQL quite easily. Rational numbers are
always the first exercice in CS courses about Abstract Data Types :-)

It's a little tricky to get good performance for all the operations:

The addition and subtraction operations are complex. They will require approximately two gcd operations, 3 divisions, 3 multiplications and
[..trimed]

(From the Booost rational package - http://www.boost.org/libs/rational/rational.html)

I'd try to link to an existing library that provides rationals, or model my code closely after one.


Yes, it may be easy to create composite type but the operands would
still be needed.

Select n FROM t WHERE frac1 < frac2;

John, do you how compatible the Booost license is (or can be made :-)
with PG, in the case where adding this to the server as a standard
datum-type might be very useful (for me anyway).

Ken

PS - Sorry for the re-send with-the-list, John




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux