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,cc6a4bc415a41111 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.8.135 with SMTP id r7mr51336565pba.8.1317467407940; Sat, 01 Oct 2011 04:10:07 -0700 (PDT) Path: lh7ni9001pbb.0!nntp.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: fixed point vs floating point References: <82lit6z64n.fsf@stephe-leake.org> Date: Sat, 01 Oct 2011 07:09:41 -0400 Message-ID: <82sjndx91m.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (windows-nt) Cancel-Lock: sha1:XpSPBWeJoYQT99FtDVS4hmUM5/Q= MIME-Version: 1.0 X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 44ea44e86f50ee029e66104394 Xref: news1.google.com comp.lang.ada:18261 Content-Type: text/plain; charset=us-ascii Date: 2011-10-01T07:09:41-04:00 List-Id: tmoran@acm.org writes: >> The only place I have found fixed point to be useful is for time; >> everything else ends up needing to be scaled, so it might as well be >> floating point from the beginning. > > Also for matching instrument or control values, formatting output, > saving memory, interfacing to C stuff, or future proofing. > > In embedded devices measurements usually come in implicitly scaled > integers, not float, as do output control values. Well, yes. I do declare fixed point types that match hardware values. But they immediately get turned into float (or time fixed point); they are not used in computations. > If Degrees is fixed point, Degrees'image is much more readable than > if it's in floating point. Put (item, fore, aft, exp) gives the same control. > Usually real world physical values don't need 32 or more bits of float > for either their range or precision. If memory size (or IO time) is > an issue, they can be stored in much smaller fixed point format. Yes; these are reasonable criteria. > Very often values passed to C et al are scaled, eg durations are > milliseconds or seconds or hundreths of seconds, represented as integers, > angles are tenths of a degree integers, and so forth. Trying to do > calculations remembering the proper scaling is error-prone, but the > compiler will do it correctly if you use fixed point. Yes. Luckily, I don't have to do that often at all :). -- -- Stephe