Re: float conversion / presentation problem ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John R Pierce <pierce(at)hogranch(dot)com>
Cc: weigelt(at)metux(dot)de, pgsql-bugs(at)postgresql(dot)org
Subject: Re: float conversion / presentation problem ?
Date: 2005-04-07 05:02:50
Message-ID: 13756.1112850170@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

John R Pierce <pierce(at)hogranch(dot)com> writes:
> Tom Lane wrote:
>> You do realize that float4/real is only good to six decimal places
>> on most platforms?

> and importantly, are stored as binary fractions. 0.10000 decimal is a
> repeating fraction in binary, its like .1100110011.... x 2^-2 or
> something as a FLOAT.

Right, and conversely a fraction that's cut off at a certain number of
base-2 digits often corresponds to a repeating pattern of base-10
digits. I once had a clue about the exact laws for this, but it was
many years ago :-(

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Neil Conway 2005-04-07 05:17:30 Re: float conversion / presentation problem ?
Previous Message John R Pierce 2005-04-07 04:40:26 Re: float conversion / presentation problem ?