| From: | Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Native type for storing fractions (e.g 1/3)? |
| Date: | 2007-03-15 13:00:32 |
| Message-ID: | 45F94370.6060609@cox.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 03/15/07 01:41, Peter Eisentraut wrote:
> Ron Johnson wrote:
>> On 03/14/07 18:55, Ken Johanson wrote:
>>> In SQL servers in general, or in PG, is there a native field type
>>> to store fractions? Or must one resort to char or separate
>>> numerator/denominator columns?
>> 1/3 repeats ad infinitum, and '1/3' would have to be converted to
>> 0.3333333333 before used in a computation, so:
>>
>> What's your ultimate purpose or goal?
>
> His goal may be to store and compute rational numbers exactly. The
> answer is that there is no data type in PostgreSQL that supports this.
>
True. However, with a composite type and stored procedures he could
fulfill that purpose.
CREATE TYPE ty_fraction AS
(
n SMALLINT,
d SMALLINT
);
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFF+UNvS9HxQb37XmcRAvmBAKDdk8CRsjUe0ziI5TIx5Yd5DIKfPACgvy3M
jfYxlhzONa8hCTrtHy/fd1Y=
=I4q8
-----END PGP SIGNATURE-----
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Stephane Bortzmeyer | 2007-03-15 13:07:41 | Re: Native type for storing fractions (e.g 1/3)? |
| Previous Message | Kynn Jones | 2007-03-15 12:59:02 | Re: Automating access grants |