Re: numeric and float converts to int differently?

From: SZŰCS 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 16:42:10
Message-ID: 074b01c39d72$6f512f90$0403a8c0@fejleszt4
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dear Ken,

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

----- Original Message -----
From: "Kenneth Marshall" <ktm(at)it(dot)is(dot)rice(dot)edu>
To: "SZŰCS Gábor" <surrano(at)mailbox(dot)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 -------------------------------

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message SZUCS Gábor 2003-10-28 17:02:14 Re: URGENT!!! changing Column size
Previous Message Tom Lane 2003-10-28 16:26:22 Re: numeric and float converts to int differently?