Re: strip zeros from fractional part

From: "Giovanni M(dot)" <drayah(at)gmail(dot)com>
To: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: strip zeros from fractional part
Date: 2005-10-03 19:14:02
Message-ID: 9216699e0510031214t4869e049k9e7395898ed1cb92@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Round and trunc dont provide the functionality I need.

Say for example I have two values in a column of type numeric as follows:
23.455
12.300

What I need to happen is stripping the "useless" zeros in the
fractional part of numbers so 12.300 would become 12.3 and 23.455
would stay the same

Round and trunc can´t do this without me first checking if the number
can indeed be "rounded" to a number without losing its precise value

On 10/3/05, Mike Nolan <nolan(at)gw(dot)tssi(dot)com> wrote:
> Have you looked at the 'round' and 'trunc' functions?
>
> > Hi guys,
> >
> > I am searching for a function that enables me to strip the trailing
> > zeros in the fractional part of a number (numeric type). For example a
> > number saved in a column of type numeric as such: 23.45000 would be
> > returned as 23.45
> >
> > I can't find any function that does this in the documentation, does
> > something like this exist or do i need to write some custom function
> > myself?
> >
> > Thanks for any help,
> >
> > Giovanni Martina
> >
> > --
> > A World of KEIGI
> > http://keigi.blogspot.com
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 3: Have you checked our extensive FAQ?
> >
> > http://www.postgresql.org/docs/faq
> >
>
>

--
A World of KEIGI
http://keigi.blogspot.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tony Wasson 2005-10-03 19:32:10 Re: strip zeros from fractional part
Previous Message Dann Corbit 2005-10-03 19:05:52 Re: strip zeros from fractional part