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,cc4f25d878383cc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-11 14:50:31 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!crtntx1-snh1.gtei.net!cambridge1-snf1.gtei.net!news.gtei.net!bos-service1.ext.raytheon.com!dfw-service2.ext.raytheon.com.POSTED!not-for-mail Message-ID: <3C168DB0.C139DC2@Raytheon.com> From: Mark Johnson X-Mailer: Mozilla 4.5 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Dimensionality Checking (Ada 20XX) References: <11bf7180.0112070815.2625851b@posting.google.com> <9v0crt$bo2bi$1@ID-25716.news.dfncis.de> <9v37rs$cdmva$1@ID-25716.news.dfncis.de> <9v5loh$d5aki$1@ID-25716.news.dfncis.de> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 11 Dec 2001 16:50:24 -0600 NNTP-Posting-Host: 192.27.48.44 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.raytheon.com 1008111030 192.27.48.44 (Tue, 11 Dec 2001 16:50:30 CST) NNTP-Posting-Date: Tue, 11 Dec 2001 16:50:30 CST Organization: Raytheon Company Xref: archiver1.google.com comp.lang.ada:17793 Date: 2001-12-11T16:50:24-06:00 List-Id: Nick Roberts wrote: > > "Stephen Leake" wrote in message > news:upu5ln22l.fsf@gsfc.nasa.gov... > [snip] > > More practically, most computers used for robotics and satellite > > simulations support fast floating point, often faster and more precise > > than integer. So there is no reason to use fixed point. > > But nothing prevents a compiler from implementing fixed point > operations/representations using the hardware's floating point unit/format. > (Am I wrong?) Its been a while since I've done fixed point arithmetic, but I believe you are wrong. A simple example using 32 bit integers and floating point. Bam_Lsb : constant := 2.0*(-32); type Bam is delta Bam_Lsb range 0.0 .. (1.0 - Bam_Lsb); About 25 years ago, we used a 16 bit version of this type for "binary angles". Zero is zero degrees, 0.5 is 180 degrees, and so on. It has a few other nice characteristics... - add and subtract is OK if modular arithmetic is supported [ignore range checks] - multiply a Bam by a fixed point range gets a useful result [work it out] - the error analysis is a lot easier [though most can't figure it out anyway :-(] and so on. You can't represent a Bam in a 32 bit floating point - not enough precision. Of course, our orbital models are now done in 64 bit floating point, so the original comment is certainly accurate on a lot of systems these days. I would tend to use fixed point for the following cases... - interfaces to hardware - small target systems - where I need absolute control of error and floating point everywhere else. --Mark