Re: numeric and float converts to int differently? - Mailing list pgsql-sql

From SZŰCS Gábor
Subject Re: numeric and float converts to int differently?
Date
Msg-id 074b01c39d72$6f512f90$0403a8c0@fejleszt4
Whole thread Raw
In response to numeric and float converts to int differently?  ("SZŰCS Gábor" <surrano@mailbox.hu>)
Responses Re: numeric and float converts to int differently?  (Greg Stark <gsstark@mit.edu>)
List pgsql-sql
Dear Ken,

reply goes to the list if you don't mind :)

----- Original Message ----- 
From: "Kenneth Marshall" <ktm@it.is.rice.edu>
To: "SZŰCS Gábor" <surrano@mailbox.hu>
Sent: Tuesday, October 28, 2003 4:45 PM


> Postgres is using the standard definition of rounding. What you

The "standard" definition I know states that 0.5 should round *up*, not
*away from zero*. i.e. 3.5 rounds (up) to 4, and -3.5 rounds (up) to -3. I
was just wondering if there is an explicit/official claim that Postgres does
round away from zero.

> 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.

This is why I asked if it's intentional/guaranteed, or undefined -- say, a
future change in glibc may cause this to change.

> I cannot imagine that the behavior would ever change.

If you can tell the developers' opinion for sure, that's enough for me :)

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



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: numeric and float converts to int differently?
Next
From: SZUCS Gábor
Date:
Subject: Re: URGENT!!! changing Column size