From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bc1441bb4023e50f X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Mon, 21 Jul 2008 10:30:40 +0200 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Financial Calculations in Ada References: <860d1$4883ccd5$45490079$7570@KNOLOGY.NET> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <48844930$0$7538$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 21 Jul 2008 10:30:40 CEST NNTP-Posting-Host: cec35943.newsspool1.arcor-online.net X-Trace: DXC=F4Fo<]lROoR1<`=YMgDjhg2O54QL:Lh>_cHTX3j=<=ki0RlbOd; X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:1234 Date: 2008-07-21T10:30:40+02:00 List-Id: Graham Stark schrieb: > On Jul 21, 12:27 am, rd <162...@gmail.com> wrote: >> I'm playing around some with Ada, and today started with the >> intent of cooking up a crappy mortgage calculator. I did the >> obvious: >> >> type Money is delta 0.01 digits 12; >> package MIO is new Ada.Text_IO.Decimal_IO (Money); use MIO; > I've been doing something similar. I would use float types if you can, > not least because the root-finding algorithms you'll have to use > probably won't work with discrete types. As someone else mentioned, > financial institutions will have policies on exactly where and how > money amounts are rounded, but it's unlikely you'll capture that just > by relying on a Decimal type. Also, consider using different types for different things, e.g. Money for display, database tables, bank accounts, ... , and user defined floats or decimals for tax rates, and again other (sub)types for interest rates and calculations reflecting above mentioned policies. -- Georg Bauhaus Y A Time Drain http://www.9toX.de