comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Simulation of fixed point in c WITH DIFFERENT BIT-WIDTH
Date: 03 Nov 2005 08:47:24 -0500
Date: 2005-11-03T08:47:24-05:00	[thread overview]
Message-ID: <wccu0etyhar.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: m2veza9s3k.fsf@grendel.local

Simon Wright <simon@pushface.org> 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



  parent reply	other threads:[~2005-11-03 13:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-30 16:41 Simulation of fixed point in c WITH DIFFERENT BIT-WIDTH mnamky
2005-10-30 17:00 ` Dmitry A. Kazakov
2005-10-30 21:46 ` Gautier Write-only
2005-11-01  2:50 ` Steve
2005-11-02 10:42 ` Colin Paul Gloster
2005-11-02 20:43   ` Gautier Write-only
2005-11-03  6:13   ` Simon Wright
2005-11-03 10:46     ` Colin Paul Gloster
2005-11-03 13:47     ` Robert A Duff [this message]
2005-11-03 14:33       ` Dmitry A. Kazakov
2005-11-03 18:19         ` Jeffrey R. Carter
2005-11-03 20:55         ` Simon Wright
2005-11-02 10:57 ` Colin Paul Gloster
2005-11-02 14:49   ` Martin Krischik
2005-11-02 20:40   ` Gautier Write-only
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox