Re: gmpy adapter - Mailing list psycopg

From Daniele Varrazzo
Subject Re: gmpy adapter
Date
Msg-id AANLkTi=GQM4CLxEZj9ugJ=m1GmDNQZa608tEkqeuAZJ9@mail.gmail.com
Whole thread Raw
In response to Re: gmpy adapter  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Responses Re: gmpy adapter  (Daniel Popowich <danielpopowich@gmail.com>)
List psycopg
On Mon, Feb 28, 2011 at 11:07 PM, Daniele Varrazzo
<daniele.varrazzo@gmail.com> wrote:

> Also notice that float64 has 53 bits of precision, 15 full decimal
> digits. If you don't need more precision when you write data in the
> database (even if you have used more during calculations) you may just
> use the repr(float()) of your mpq to write into the database.

Or else, in the adapter you may use mpf to approximate the rational to
the precision you need.

    >>> gmpy.mpq(2,3)
    mpq(2,3)
    >>> gmpy.mpf(_, 100)
    mpf('6.666666666666666666666666666666666666667e-1',100)
    >>> str(_)
    '0.6666666666666666666666666666666666666667'

-- Daniele

psycopg by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Re: gmpy adapter
Next
From: Daniele Varrazzo
Date:
Subject: Re: gmpy adapter