From f5e524d92be609c709825be8995bf77f10880c3b Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 5 Apr 2011 09:35:43 -0400 Subject: Add casts from int4 and int8 to numeric. Joey Adams, per gripe from Ramanujam. Review by myself and Tom Lane. --- doc/src/sgml/datatype.sgml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'doc/src') 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 tablename_ - Values of the numeric data type can be cast to - money. Other numeric types can be converted to - money by casting to numeric first, for example: + Values of the numeric, int, and + bigint data types can be cast to money. + Conversion from the real and double precision + data types can be done by casting to numeric first, for + example: -SELECT 1234::numeric::money; +SELECT '12.34'::float8::numeric::money; + However, this is not recommended. Floating point numbers should not be + used to handle money due to the potential for rounding errors. + + + A money value can be cast to numeric 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: SELECT '52093.89'::money::numeric::float8; -- cgit v1.2.3