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,6a8952cbe009f3ed X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.224.189.78 with SMTP id dd14mr3492805qab.0.1358439361349; Thu, 17 Jan 2013 08:16:01 -0800 (PST) X-Received: by 10.49.116.34 with SMTP id jt2mr1280737qeb.38.1358439361322; Thu, 17 Jan 2013 08:16:01 -0800 (PST) Path: k2ni675qap.0!nntp.google.com!p13no1029594qai.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 17 Jan 2013 08:16:00 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ NNTP-Posting-Host: 66.126.103.122 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Numerical calculations: Why not use fixed point types for everything? From: Adam Beneschan Injection-Date: Thu, 17 Jan 2013 16:16:01 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2013-01-17T08:16:00-08:00 List-Id: On Thursday, January 17, 2013 6:40:04 AM UTC-8, Nasser M. Abbasi wrote: > On 01/17/2013 04:33 AM, Ada novice wrote: >=20 > > I understand that it is a question of portability as well > >as the actual delta that would be used would perhaps not be > >the same for all machines and for all compilers. >=20 > There is good article on this here: >=20 > http://www.dspguide.com/ch28/4.htm >=20 >=20 >=20 > (this assumes the hardware can run both floating > point and fixed point, not all hardware supports > fixed point. From the above it says >=20 > "fixed point DSPs are generally cheaper, while floating > point devices have better precision, higher dynamic range, > and a shorter development cycle" >=20 > I suppose if the hardware does not support fixed point, > this is handled by a software library or the run-time, and > will be slower than floating point. I don't know if there's really such a thing as hardware that doesn't suppor= t "fixed-point." From an Ada standpoint, and probably from other standpoin= ts as well, fixed-point numbers are just integers, where the compiler knows= internally that each integer N actually represents the value N * S where S= is the scale factor (which is usually 2**(-m) for some positive integer m,= or 10**(-m) for decimal fixed-point, but implementations are allowed to su= pport other scale factors), but the hardware doesn't know about the scale f= actor. Arithmetic operations on fixed-point values are just implemented as= operations on integers, sometimes with some extra multiplication or divisi= on (which can sometimes be accomplished with shifting) to make the scale fa= ctors match. =20 The article you reference uses SHARC as one of its examples of DSP's that s= upport fixed-point. My copy of ADSP-2106x SHARC(tm) User's Manual describe= s fixed-point numbers as "They may be treated as fractional or integer numb= ers and as unsigned or twos-complement". Throughout the manual, the descri= ptions use "fixed-point" in this way--the hardware is really treating the n= umbers as integers, and it's up to the programmer or compiler to know wheth= er they really represent integers or not, but the manual is just using that= term instead of "integer". =20 So if this is typically how the term is used, then hardware that doesn't su= pport fixed-point is really hardware that doesn't support integers, and AFA= IK there has never been any processor in the history of computing that does= n't support integer arithmetic. -- Adam