Lists: | pgsql-hackers |
---|
From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | float value is rounded |
Date: | 2009-11-25 18:21:06 |
Message-ID: | 162867790911251021w497da616r53b0a46002249117@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hello
I was surprised with rounding relative not big value. Is it correct?
postgres=# select 499188.546875::real;
float4
────────
499189
(1 row)
regards
Pavel Stehule
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: float value is rounded |
Date: | 2009-11-25 18:39:49 |
Message-ID: | 22820.1259174389@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
> I was surprised with rounding relative not big value. Is it correct?
You do realize float4 has only 6 decimal digits of precision?
regards, tom lane
From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: float value is rounded |
Date: | 2009-11-25 18:46:11 |
Message-ID: | 162867790911251046v769db287s67b5edd0061ea913@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
2009/11/25 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>> I was surprised with rounding relative not big value. Is it correct?
>
> You do realize float4 has only 6 decimal digits of precision?
>
To today I though so float4 is more practical :).
I am smarter now
Pavel
> regards, tom lane
>
From: | David Fetter <david(at)fetter(dot)org> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: float value is rounded |
Date: | 2009-11-26 00:32:04 |
Message-ID: | 20091126003204.GA13542@fetter.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Wed, Nov 25, 2009 at 07:46:11PM +0100, Pavel Stehule wrote:
> 2009/11/25 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> > Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
> >> I was surprised with rounding relative not big value. Is it
> >> correct?
> >
> > You do realize float4 has only 6 decimal digits of precision?
> >
>
> To today I though so float4 is more practical :).
Floats have never been safe with respect to operations like =, and
won't become so.
Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate