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=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fedc2d05e82c9174 X-Google-Attributes: gid103376,public From: "bob" Subject: Re: Calculating SQRT in ADA Date: 1999/03/26 Message-ID: <01be7799$f7b9c080$0e2915c0@w95>#1/1 X-Deja-AN: 459365601 References: <01be7613$c90ed040$0e2915c0@w95> <36F94393.5D1B317D@icon.fi> Organization: B & D Associates X-NETCOM-Date: Fri Mar 26 9:04:22 AM CST 1999 Newsgroups: comp.lang.ada Date: 1999-03-26T09:04:22-06:00 List-Id: Niklas Holsti wrote in article <36F94393.5D1B317D@icon.fi>... > bob wrote: > > [snip] > > > In Ada83 or Ada95, if the target is real, possibly the following: > > x : real; > > [snip] > > x = x**0.5; > > Nope, for the standard "**" the right operand must be integer > (Integer'Base, actually). Agree for the standard. However many supply packages for the real**real. One that comes to mind immediately is "Ada.Numerics.Generic_Elementary_Functions in gnat. with Ada.Numerics.Generic_Elementary_Functions; with text_io; use text_io; procedure sqrt is subtype real is long_float; package math is new Ada.Numerics.Generic_Elementary_Functions(real); use math; package fio is new text_io.float_io(real); use fio; x : real := 2.3; begin put(" The sqrt of "); put(x); put(" is "); put(x**0.5); new_line; end sqrt; ada sqrt.adb gcc -c -g sqrt.adb gnatbind -x sqrt.ali gnatlink -g sqrt.ali linux:~/atest> sqrt The sqrt of 2.30000000000000E+00 is 1.51657508881031E+00 > > > All of the Ada85 comilers I have used supply a "math" package > > containing sqrt also. > > That agrees with my experience and would be the first place to > look. > > Niklas Holsti > Working at but not speaking for Space Systems Finland Ltd. > cheers