pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feednumeric conversions?
2+ messages / 2 participants
[nested] [flat]
* numeric conversions?
@ 2000-11-20 15:51 Bruno Boettcher <bboett@erm1.u-strasbg.fr>
0 siblings, 1 reply; 2+ messages in thread
From: Bruno Boettcher @ 2000-11-20 15:51 UTC (permalink / raw)
To: pgsql-sql
Hello,
me again :(
i just ran into another problem....
didn't found it neither in the doc nor in the FAQ.....
the currencies conversion factors i use are stored as float4 in a table,
the values to apply on are stores as int4 ....
is the type casting done automaticly? how? can i have an influence of
the cast order? is there an easy way to doing the rounding?
the operation i want to do is something along this line:
int4 = ((int4) float4 * (float4)int4 +.5);
--
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
===============================================================
the total amount of intelligence on earth is constant.
human population is growing....
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: numeric conversions?
@ 2000-11-20 15:59 Jonathan Ellis <jellis@advocast.com>
parent: Bruno Boettcher <bboett@erm1.u-strasbg.fr>
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Ellis @ 2000-11-20 15:59 UTC (permalink / raw)
To: pgsql-sql
> is the type casting done automaticly? how? can i have an influence of
> the cast order? is there an easy way to doing the rounding?
bf2=# select 1 / 2 from dual;
?column?
----------
0
(1 row)
bf2=# select 1::float / 2 from dual;
?column?
----------
0.5
(1 row)
bf2=# select (1::float / 2)::int from dual;
?column?
----------
0
(1 row)
Also you have the functions round, floor, and ceil, which do what you would
expect.
-Jonathan
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2000-11-20 15:59 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-11-20 15:51 numeric conversions? Bruno Boettcher <bboett@erm1.u-strasbg.fr>
2000-11-20 15:59 ` Jonathan Ellis <jellis@advocast.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox