Re: (Bug) Numeric fault calculation - Mailing list pgadmin-support

From Guillaume Lelarge
Subject Re: (Bug) Numeric fault calculation
Date
Msg-id 1371589776.2530.40.camel@localhost.localdomain
Whole thread Raw
In response to Re: (Bug) Numeric fault calculation  (Chirag Mittal <linux@seasonstravel.co.in>)
Responses Re: (Bug) Numeric fault calculation
Re: (Bug) Numeric fault calculation
List 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




pgadmin-support by date:

Previous
From: AI Rumman
Date:
Subject: Re: [GENERAL] Postgres DB crashing
Next
From: Guillaume Lelarge
Date:
Subject: Re: SQL editor view, Add favourite disabled