From: eagle!jerry
Subject: Re: Fixed point data in Ada
Date: Thu Nov 4 02:01:27 1982
Date: 1982-11-04T02:01:27+00:00 [thread overview]
Date: Wed Nov 3 10:18:38 1982
Message-ID: <bnews.eagle.593> (raw)
In-Reply-To: bnews.duke.2719
This subject is more complicated than meets the eye.
I will present some statements from the LRM
LRM 3.5.9-3 defines the "delta" of an Ada
fixed point type as the value given in the declaration
which may be any positive real value.
LRM 3.5.9-4 says that the "model numbers" for
a fixed point type are multiples of "small"
LRM 3.5.9-5 says "the number small is
choosen as the largest power of two that is not greater
than the specified delta. Alternatively, it is
possible to specify the value of small by a length clause.
(see 13.2)"
LRM 13.2 defines "length clauses" which are a particular
kind of "representation clause". In particular LRM 13.2-9
Defines a clause of the form
for T'small use simple_expression
and says "the type T must be a fixed point type. The expression
must be a static expression of some real type; its value
must not be greater than the delta of the type. The effect
of the length clause is to use this value of small for the
representation of values of the fixed point type."
Taking all the above together it would seem that dollars
could be specified by
type money is delta .01 ;
for money'small use .01 ;
This should get a representation in which values of type
money are represented in "cents".
Great! But before you get excited let me quote one more
paragraph of the LRM 3.5.9-11: "The fixed point declaration
is illegal if no implementation defined type satisfies
these requirements". (There must be at least
one anonymous fixed point type according to LRM 3.5.9-7)
My interpretation of this is: if your Ada compiler accepts the
declaration and length clause it will give you the
representation you want. But there is no guarantee
that it will accept it.
I hope this clears up some of the confusion.
Jerry Schwarz
harpo!eagle!jerry
prev parent reply other threads:[~1982-11-04 2:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1982-11-02 6:28 Fixed point data in Ada duke!bcw
1982-11-02 12:30 ` utcsrgv!donald
1982-11-04 2:01 ` eagle!jerry [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox