Re: (Bug) Numeric fault calculation

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: Chirag Mittal <linux(at)seasonstravel(dot)co(dot)in>
Cc: pgadmin-support(at)postgresql(dot)org
Subject: Re: (Bug) Numeric fault calculation
Date: 2013-06-18 21:09:36
Message-ID: 1371589776.2530.40.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

On Sun, 2013-06-16 at 04:59 -0700, Chirag Mittal wrote:
> Dear Kanitchet,
>
> Please try this
>
> SELECT (260739.94 * (1.00/365.00))::numeric(20,7)
>
> I am a beginner but I think we need to explicitly mention the "output"
> format required to get accuracy.
>

Nope, you simply need to use the right datatype. If you use a floating
point datatype (which is what happens when you don't specificy the
type), you cannot claim to get exact precision. If you need the
accuracy, you need the numeric datatype (just as you did with the query
above).

--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com

In response to

Responses

Browse pgadmin-support by date

  From Date Subject
Next Message Guillaume Lelarge 2013-06-18 21:12:54 Re: SQL editor view, Add favourite disabled
Previous Message John R Pierce 2013-06-18 18:17:25 Re: Postgres DB crashing