Dear Gurus,

I'm using PostgreSQL 7.3.3.

I was wondering if this is undefined, intentional or to be changed/fixed in
the future. See the snippit at the end of this mail.

QUESTION 1: Is it intentional that converting 0.5 to int4
- from numeric: rounds *away from* zero
- from float: rounds *towards* zero (tried float4 and float8 too)?

QUESTION 2: Is it safe to assume it won't change (haven't changed) in the
upcoming versions?

QUESTION 3: Is there a function or conversion method that converts 0.5
according to
- mathematical rules (*up*)
- accounting rules (*down*, at least here in Hungary)?

TIA,

G.
------------------------------- cut here -------------------------------
# select int4('0.5'::numeric);
    1
# select int4('-0.5'::numeric);
   -1
# select int4('0.5'::float);
    0
# select int4('-0.5'::float);
    0
------------------------------- cut here -------------------------------
What I would really like to see:
# select round_math('0.5');
    1
# select round_math('-0.5');
    0
# select round_acct('0.5');
    0
# select round_acct('-0.5');
   -1
------------------------------- cut here -------------------------------


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to