Search Postgresql Archives

Re: chop off non-meaningful digits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I just noticed this one:

postgres=# select  1000.000::float;
 float8
--------
   1000
(1 row)

postgres=# select  1000.0001::float;
  float8
-----------
 1000.0001
(1 row)

postgres=# select  1000.000100::float;
  float8
-----------
 1000.0001
(1 row)

postgres=#

HTH,

Best regards,

--
gurjeet[.singh]@EnterpriseDB.com
singh.gurjeet@{ gmail | hotmail | yahoo }.com

On 11/14/06, Berend Tober <btober@xxxxxxxxxxxxxxxx> wrote:
A. Kretschmer wrote:
> am  Tue, dem 14.11.2006, um  0:58:56 -0500 mailte Tom Lane folgendes:
>
>> "SunWuKung" <Balazs.Klein@xxxxxxxxxxx> writes:
>>
>>> Yep, I think this is it:
>>> select trim(trailing '0.' from 1.020)
>>>
>> Um, I think not:
>>
>> regression=# select trim(trailing '0.' from 1000.000);
>>  rtrim
>> -------
>>  1
>> (1 row)
>>
> For this case:
>
> test=*> select trim(trailing '.' from trim(trailing '0' from 1000.000));
>  rtrim
> -------
>  1000
>

Perhaps the OP doesn't really care about this, but FWIW one thing I
recall from high school science (or maybe it was middle school), the
zeros to the right of the decimal place ARE meaningful, i.e., 1000.000
signifies something different than 1000, namely, a measurement three
orders of magnitude more precise.  So "chopping off non-meaningful
digits" is something you ought to do only for zeros on the left.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux