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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9dfd83e22ef315db,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-14 19:39:15 PST Path: supernews.google.com!sn-xit-02!supernews.com!isdnet!newscore.gigabell.net!newsfeed00.sul.t-online.de!t-online.de!news1.dtag.de!news.dvz-mv.de!ngen.mteege.de!nobody From: Matthias Teege Newsgroups: comp.lang.ada Subject: exponentiation of fixed point or decimal Date: 14 Dec 2000 19:24:53 +0100 Organization: DVZ Datenverarbeitungszentrum Mecklenburg-Vorpommern GmbH Sender: matthias@moon.mteege.de Message-ID: <87hf46uah6.fsf@moon.mteege.de> NNTP-Posting-Host: ppps-nb01.mvnet.de Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.5 Xref: supernews.google.com comp.lang.ada:3158 Date: 2000-12-14T19:24:53+01:00 List-Id: Moin, I have a question about exponentiation of fixed point typs. The following code didnt compile because of the '**' operator is not defined for fixed point typs. So I made a lot of type conversions from my fixed point type to float but the result for an Var_B of 10000 differs 0.01 of what my desk calculator says. I have also made test with the numerics packages. If I use reals there will be a better result but my "application" is for financial transactions and I think fixed point or decimal is the best choice. Is there any way for an exponentiation of fixed types? procedure test is Max_Delta : constant := 0.001; Max_Digits : constant := 15; type MyDec is delta Max_Delta digits Max_Digits; package MyDec_IO is new Ada.Text_IO.Decimal_IO(MyDec); Var_A: MyDec := 5.00; Var_B: MyDec; function myfunc(K: MyDec; Z: MyDec; Count: Positive ) return MyDec is begin return K * (1.00 + Z / 100) ** Count; -- return MyDec(Float(K) * Float((1.00 + Z / 100)) ** Count); end myfunc; Begin MyDec_IO.Get(Var_B); MyDec_IO.Put(myfunc(Var_B, 5.00, 5), EXP=>0, FORE=>2, AFT=>2); end test; Many thanks Matthias -- Matthias Teege -- matthias@mteege.de -- http://emugs.de make world not war PGP-Key auf Anfrage