Re: numeric and float converts to int differently?

From: SZUCS Gábor <surrano(at)mailbox(dot)hu>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: numeric and float converts to int differently?
Date: 2003-10-28 20:16:53
Message-ID: 0acb01c39d90$6d9d9080$0403a8c0@fejleszt4
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

----- Original Message -----
From: "Greg Stark" <gsstark(at)mit(dot)edu>
Sent: Tuesday, October 28, 2003 7:21 PM

> > > cannot see is that the float values are not actually exactly 0.5
> >
> > Yes I could guess that (floating point vs fixed), but is this a
coincidence
> > that both '0.5'::float and '-0.5'::float are closer to 0, whereas they
could
> > be closer to +/-1, as well as both closer to the lower or upper bound.
>
> Wouldn't 0.5 and -0.5 be representable exactly as floats?

As Tom pointed out, it isn't a floating point failure -- it is how rounding
float is implemented. I assume anything with less than 15 digits can be
exactly represented as float.

G.
------------------------------- cut here -------------------------------

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bruno Wolff III 2003-10-28 20:31:19 Re: numeric and float converts to int differently?
Previous Message Greg Stark 2003-10-28 18:21:17 Re: numeric and float converts to int differently?