Re: The 85/0.0085 mistery ?

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, fwr(at)ga(dot)prestige(dot)net, "'Jean-Christophe Pazzaglia'" <jc(dot)pazzaglia(at)albourne(dot)com>, "'PostgreSQL-development'" <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: The 85/0.0085 mistery ?
Date: 2000-10-06 14:36:30
Message-ID: 39DDE36E.E9FE04BC@tm.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hannu Krosing wrote:
>
> Tom Lane wrote:
> >
> > "Frederick W. Reimer" <fwr(at)ga(dot)prestige(dot)net> writes:
> > > In general, it's recommended you don't check for exact equivalence when
> > > doing calculations on real numbers and instead check for "almost exactness."
> >
>
> perhaps "where trunc(85/0.0085) = 10000" works better.

ok I tested it and it does not work ;(

hannu=# select trunc(85.0::float4/0.0085::float4) = '10000';
ERROR: Function 'trunc(float4)' does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts
hannu=# select trunc(float8(85.0::float4/0.0085::float4));
trunc
-------
9999
(1 row)

But this does work

hannu=# select text(85.0::float4/0.0085::float4) = '10000';
?column?
----------
t
(1 row)

As does this

hannu=# select round(float8(85.0::float4/0.0085::float4));
round
-------
10000
(1 row)

--------------
Hannu

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-10-06 14:58:58 Re: The 85/0.0085 mistery ?
Previous Message Hannu Krosing 2000-10-06 14:23:19 Re: The 85/0.0085 mistery ?