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!news2.google.com!news1.google.com!news.glorb.com!feeder.erje.net!news.motzarella.org!motzarella.org!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: Financial Calculations in Ada Date: Sun, 20 Jul 2008 19:32:52 -0700 Organization: None to speak of Message-ID: References: <860d1$4883ccd5$45490079$7570@KNOLOGY.NET> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: feeder.motzarella.org U2FsdGVkX18dU1Gt1lyTmn6OEZgmMo1EtWJgeVOsg+QN0yJyus/xtVFDbijioBKAfIRYpQZSuwshB5/a5QIzYi00rYLtLY+fbobxeDJ5naFJOwI7rf//oLpbO6uJEPfrqlxDkqjmJHQ= X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Mon, 21 Jul 2008 02:32:53 +0000 (UTC) X-Auth-Sender: U2FsdGVkX1/h0BEQNamlmSBqG/V+AmQF Cancel-Lock: sha1:KAQvvjHU3T/G951fPCv4CMpuaZM= sha1:hN9nU50+dNkToQCubmcgDjOzJIU= User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (gnu/linux) Xref: g2news1.google.com comp.lang.ada:1230 Date: 2008-07-20T19:32:52-07:00 List-Id: rd <162144@gmail.com> writes: > 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? An interest rate isn't an amount of money, so don't use type Money to represent it. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Nokia "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"