comp.lang.ada
 help / color / mirror / Atom feed
From: Graham Stark <graham.stark@virtual-worlds.biz>
Subject: Re: Financial Calculations in Ada
Date: Mon, 21 Jul 2008 01:24:29 -0700 (PDT)
Date: 2008-07-21T01:24:29-07:00	[thread overview]
Message-ID: <e219b06b-2977-4f96-83ee-14507a25db49@t54g2000hsg.googlegroups.com> (raw)
In-Reply-To: 860d1$4883ccd5$45490079$7570@KNOLOGY.NET

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 hit a brick wall more quickly than usual in that I couldn't
> figure out a good way to handle interest rates that might have
> a decimal value with more digits than my Money type, such as 7.125.
>
> Can anyone give me any tips on how to handle this sort of thing
> in Ada?
>
> --
> rd

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.



  parent reply	other threads:[~2008-07-21  8:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-20 23:27 Financial Calculations in Ada rd
2008-07-21  2:32 ` Keith Thompson
2008-07-21  5:11   ` tmoran
2008-07-21  4:46 ` Gautier
2008-07-21  8:24 ` Graham Stark [this message]
2008-07-21  8:30   ` Georg Bauhaus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox