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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6a8952cbe009f3ed X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII X-Received: by 10.68.226.168 with SMTP id rt8mr1525335pbc.8.1358550418014; Fri, 18 Jan 2013 15:06:58 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.50.220.231 with SMTP id pz7mr1288021igc.8.1358550417968; Fri, 18 Jan 2013 15:06:57 -0800 (PST) Path: 6ni3747pbd.1!nntp.google.com!f6no9667918pbd.1!postnews.google.com!th3g2000pbc.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 18 Jan 2013 15:06:57 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: th3g2000pbc.googlegroups.com; posting-host=123.2.70.40; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le NNTP-Posting-Host: 123.2.70.40 References: <4905b963-0036-4129-8050-fb26ef0154d6@googlegroups.com> <32314026-23ae-45b8-a4c5-e589e7d79de2@googlegroups.com> <3l3jf85ae05qgsl2l0avomebmg2ogl17rq@invalid.netcom.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1,gzip(gfe) Message-ID: <23f3f31f-1f8b-4f04-98ce-025b7a81e3e0@th3g2000pbc.googlegroups.com> Subject: Re: Numerical calculations: Why not use fixed point types for everything? From: Robin Vowels Injection-Date: Fri, 18 Jan 2013 23:06:58 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2013-01-18T15:06:57-08:00 List-Id: On Jan 19, 5:15=A0am, Dennis Lee Bieber wrote: > On Fri, 18 Jan 2013 01:17:37 -0800 (PST), Ada novice > declaimed the following in comp.lang.ada: > > > > > I have read (John Mc Cormick: Building parallel...with Ada's book) that= fixed point arithmetic is faster than floating-point arithmetic since inte= ger instructions are faster so I would ask about the second point put by Ad= am that mathematical functions are slow with fixed-point numbers. Can you p= lease elaborate on that? > > =A0 =A0 =A0 =A0 Integer operations may be faster than floating point... B= ut fixed > point with a non-zero decimal place add in the overhead of having to > track where the point is and shifting results to match the declared data > type. > > 25 * 25 =3D> 725 > > 2.5 * 2.5 =3D> 7.25 -- but if the data type is only one decimal place thi= s > now has to be rounded and shifted to become 7.3. > > =A0 =A0 =A0 =A0 All these adjustments and tracking are being done at the = high-level > instruction set, not in the processor hardware. In contrast, a floating > point processor does all the mantissa and exponent adjustments in the > hardware, which may be faster than having to do things like -- > > ld i1, 25 > mult i1, 25 > add i1, 5 > div i1, 10 It may not be like that at all. In the first place, 25 is a constant. In the second place, adjusting the value (scaling) is achieved with a shift, not an actual division by 10. Thus, multiplication is simply multiply a,b shift.rounded a > -- the sequence to treat integer registers as fixed 1-decimal place data > compared to (the add/div would be added by the compiler based upon the > number of decimal places to be kept in the result, based upon the number > of places that were in the source > > ld f1, 2.5E0 > mult f1, 2.5E0