Received: from wallace.ece.rice.edu (wallace.ece.rice.edu [128.42.12.154]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3HHfFu88768 for ; Tue, 17 Apr 2001 13:41:15 -0400 (EDT) (envelope-from reedstrm@rice.edu) Received: by rice.edu via sendmail from stdin id (Debian Smail3.2.0.102) for pgsql-sql@postgresql.org; Tue, 17 Apr 2001 12:41:04 -0500 (CDT) Date: Tue, 17 Apr 2001 12:41:04 -0500 From: "Ross J. Reedstrom" To: Mark Stosberg Cc: pgsql-sql@postgresql.org Subject: Re: function to format floats as money? Message-ID: <20010417124104.C17425@rice.edu> Mail-Followup-To: Mark Stosberg , pgsql-sql@postgresql.org References: <3ADC61E0.93E7865D@summersault.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.0i In-Reply-To: <3ADC61E0.93E7865D@summersault.com>; from mark@summersault.com on Tue, Apr 17, 2001 at 10:31:49AM -0500 X-Archive-Number: 200104/272 X-Sequence-Number: 2627 On Tue, Apr 17, 2001 at 10:31:49AM -0500, Mark Stosberg wrote: > Peter Eisentraut wrote: > > > > Mark Stosberg writes: > > > > > I'm curious to know if there is a function available in Postgres 7.0.3 > > > (or 7.1) that will format a float style number as "money". I understand > > > that the money type is going away in the future, so using a float type > > > that is sometimes formatted like money seems like a good alternative. So > > > ideally, I'm looking for a solution that won't go away when the money type > > > does. :) Thanks! > > > > to_char() for formatting. > > > > numeric for storage. > > > > Using floats for monetary amounts is not only an extremely bad idea > > because of the inexactness of storage and arithmetic, it might even be > > illegal if you're using it for official purposes. > > Thanks Peter. > > So if the money type is going away, and floats can be illegal, whats > the best way to store money? Why, in the bank, or under your mattress, depending on your level of paranoia, of course. But seriously, numeric(10,2) (or whatever precision and scale is correct for your application) is the standard answer. Ross