Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: [GENERAL] Simple math statement - problem

From: Gregory Williamson <Gregory.Williamson(at)digitalglobe.com>
Date: Fri Nov 30 2007 - 00:47:44 EST


A quick experiment shows that if either numerator or denominator are decimal, that is preserved in the end result. Probably true for basic math operations in general.

GW

-----Original Message-----
From: pgsql-general-owner@postgresql.org on behalf of Gregory Williamson Sent: Thu 11/29/2007 10:37 PM
To: Postgres User; pgsql-general
Subject: Re: [GENERAL] Simple math statement - problem  

The question:
>
> How can I write statements that returns a decimal?
>
>

billing=# select 1/100;
 ?column?


        0
(1 row)

As you said ...

So make everything decimal:
billing=# select 1.0/100.0;

        ?column?


 0.01000000000000000000
Do you need help?X

Or:
billing=# select 1::decimal/100::decimal;

        ?column?


 0.01000000000000000000

I think that when you use integers you lose precision right out the gate. Others can provide better insight I hope ...

HTH, Greg Williamson
Senior DBA
GlobeXplorer LLC, a DigitalGlobe company

Confidentiality Notice: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information and must be protected in accordance with those provisions. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

(My corporate masters made me say this.) Received on Fri Nov 30 05:05:14 2007

This archive was generated by hypermail 2.1.8 : Mon Jun 16 2008 - 20:57:51 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library