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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!batcomputer!itsgw!steinmetz!uunet!mcvax!enea!sommar From: sommar@enea.se (Erland Sommarskog) Newsgroups: comp.lang.ada Subject: Re: Ada and Decimal Arithmetic Message-ID: <3663@enea.se> Date: 6 Jul 88 19:12:01 GMT Organization: ENEA DATA AB, Sweden List-Id: Marc.Graham@SEI.CMU.EDU writes: >I was fascinated to note that in neither Ed Berard's post on Ada and >commercial usage, nor in any of its responses, was the issue of Ada >and decimal arithmetic mentioned. I would have thought that Ada's lack >of support for decimal arithmetic is a major impediment to the use of >Ada in commercial applications. Indeed, if I were asked to render a >professional judgement on Ada to a commercial client, lack of decimal >support would in itself be enough to reject it. While it is true that Ada does not contain itself decimal arithmetic accurate to the last bit, it is easy to implement. Basically: Package Decimal_arithmetic is Type Fixed_point(No_of_dec : Natural) is private; -- Possibly limited -- Operations on Fixed_point, arithmetics and I/O. Private Type Fixed_point(No_of_dec : Natural) is -- for instance Record Int_part : integer; Fractional : integer; End record; End package; What you miss is that you can't have fixed point literals. 1.02 may not reliable. But this easy solved with a Set_fixed_point operation that takes two integer parameters. Someone pointed out that to count your money, you may as well count in cents. This is perfectly true. However, the problem arises when you have things like interest rates. I'm working with a commercial application for the moment. We use VAX-Pascal, so we don't have the same possibilities for abstract data types as in Ada. And when you are dealing with a percent figure, you must know whether it's 0, 2 or 4 decimals for this one. If two people interpret it differently, an error will be introduced. Being in the line of scaled integers: If one believe that this is a problem which occurs only in commercial applications, one is wrong. My project before this one was a graphical package to be used in radar systems. We used scaled integers. Due to real-time requirements we had no time for floating point calcualations. -- Erland Sommarskog ENEA Data, Stockholm sommar@enea.UUCP "It all looks quite impressive really, but is it really necessary?" Radio Stars