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

From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Native type for storing fractions (e.g 1/3)?
Date: 2007-03-15 20:11:23
Message-ID: 45F9A86B.30509@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ron Johnson wrote:
> CREATE TYPE ty_fraction AS
> (
> n SMALLINT,
> d SMALLINT
> );

You'd need a type for large integers first - otherwise your
ty_fraction will be quite limited. I think numeric could be
used for that, though I don't know if numeric guarantees that
at least the operators +,-,* and modulo return exact results
(Don't loose digits). But even if they do, using some existing
library for arbitrary sized integers would probably lead to
better performance.

greetings, Florian Pflug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Florian G. Pflug 2007-03-15 20:15:10 Re: Problem to install pgAdmin
Previous Message Florian G. Pflug 2007-03-15 19:58:15 Re: PITR and WAL archiving