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,509f8e43dc081fde X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Simulation of fixed point in c WITH DIFFERENT BIT-WIDTH Date: 03 Nov 2005 08:47:24 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1130690498.388857.225170@g49g2000cwa.googlegroups.com> <1130690498.388857.225170@g49g2000cwa.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1131025644 7971 192.74.137.71 (3 Nov 2005 13:47:24 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 3 Nov 2005 13:47:24 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:6140 Date: 2005-11-03T08:47:24-05:00 List-Id: Simon Wright writes: > I'm not sure what is actually required for portability here. AARM95 > 3.5.9(22-24) says > > The base range of an ordinary fixed point type need not include the > specified bounds themselves so that the range specification can be > given in a natural way, such as: > > type Fraction is delta 2.0**(-15) range -1.0 .. 1.0; > > With 2's complement hardware, such a type could have a signed > 16-bit representation, using 1 bit for the sign and 15 bits for > fraction, resulting in a base range of -1.0 .. 1.0-2.0**(-15). This is a language design flaw, in my opinion. "T'Last in T" and "T'Last in T'Base" should both always be true. If you want 16 bits, you should say "-1.0 .. 1.0-2.0**(-15)." After all, we don't play these games with integers -- if you say "range -2**15..2**15", you get at least 17 bits (probably 32 bits). The "need not" in the above wording means that the implementation has a choice. It can include 1.0 in the base range of Fraction, or not. Some implementations will include the upper bound if and only if it does not require extra bits. I think that kind of non-portability is unhelpful to programmers. - Bob