aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2011-04-05 09:35:43 -0400
committerRobert Haas <rhaas@postgresql.org>2011-04-05 09:35:43 -0400
commitf5e524d92be609c709825be8995bf77f10880c3b (patch)
tree6b3a1754ad3c06f1146a632a77fcc56c7d23e1d1 /doc/src
parent88f32b7ca29982f286b61a9d0dd29be4b8a01c25 (diff)
downloadpostgresql-f5e524d92be609c709825be8995bf77f10880c3b.tar.gz
postgresql-f5e524d92be609c709825be8995bf77f10880c3b.zip
Add casts from int4 and int8 to numeric.
Joey Adams, per gripe from Ramanujam. Review by myself and Tom Lane.
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/datatype.sgml17
1 files changed, 12 insertions, 5 deletions
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index ecc79e27fc3..13b888dff8f 100644
--- a/doc/src/sgml/datatype.sgml
+++ b/doc/src/sgml/datatype.sgml
@@ -886,15 +886,22 @@ ALTER SEQUENCE <replaceable class="parameter">tablename</replaceable>_<replaceab
</para>
<para>
- Values of the <type>numeric</type> data type can be cast to
- <type>money</type>. Other numeric types can be converted to
- <type>money</type> by casting to <type>numeric</type> first, for example:
+ Values of the <type>numeric</type>, <type>int</type>, and
+ <type>bigint</type> data types can be cast to <type>money</type>.
+ Conversion from the <type>real</type> and <type>double precision</type>
+ data types can be done by casting to <type>numeric</type> first, for
+ example:
<programlisting>
-SELECT 1234::numeric::money;
+SELECT '12.34'::float8::numeric::money;
</programlisting>
+ However, this is not recommended. Floating point numbers should not be
+ used to handle money due to the potential for rounding errors.
+ </para>
+
+ <para>
A <type>money</type> value can be cast to <type>numeric</type> without
loss of precision. Conversion to other types could potentially lose
- precision, and it must be done in two stages, for example:
+ precision, and must also be done in two stages:
<programlisting>
SELECT '52093.89'::money::numeric::float8;
</programlisting>