[net.lang.ada] The AFT Attribute

Mendal@SIERRA.STANFORD.EDU (Geoff Mendal) (09/16/86)

Hello Ada Fans,

I'm confused again.  In the LRM, 3.5.10(9) states (parenthetically)
that the value of the AFT attribute is the smallest positive N
such that (10 ** N) * T'DELTA >= 1.0.  Now, 3.5.10(15) states that
the value returned by AFT depends only on T'DELTA. [3.5.10(15) is
a "note".]

Can these two paragraphs imply a cohesive semantics for the AFT
attribute?  Using 3.5.10(9) on the following type:

  type Fix is delta 1.0 / 16.0 range 0.0 .. 1.0;

The smallest value N that satisfies the equation is 2.  But how can
one represent 1.0 / 16.0 accurately in two decimal digits?
[1.0 / 16.0 = 0.0625]

What am I missing here?

gom
-------

stt@ada-uts (09/22/86)

In 3.5.10:9, the RM says "T'AFT yields the number of decimal
digits needed after the point to accommodate the precision
of the subtype T,..."  The key word is "accommodate," which is being
used in a way that is consistent with the definition of
DELTA itself, namely that the DELTA represents an upper bound
on the actual delta.  For T'AFT, it is an upper bound on the
value of a 1 in the last position.  In your example, the
relevant equation is that 0.01 <= 0.0625, not that the
decimal expansion of 1/16 requires 4 digits.  Otherwise,
imagine what the T'AFT would be for 1/3.

By the way, T'AFT is my favorite attribute.
-S. Tucker T'aft
 Intermetrics, Inc.
 733 Concord Ave.
 Cambridge, MA  02138

drw@cullvax.UUCP (Dale Worley) (09/22/86)

> I'm confused again.  In the LRM, 3.5.10(9) states (parenthetically)
> that the value of the AFT attribute is the smallest positive N
> such that (10 ** N) * T'DELTA >= 1.0.  Now, 3.5.10(15) states that
> the value returned by AFT depends only on T'DELTA. [3.5.10(15) is
> a "note".]
> 
> Can these two paragraphs imply a cohesive semantics for the AFT
> attribute?  Using 3.5.10(9) on the following type:
> 
>   type Fix is delta 1.0 / 16.0 range 0.0 .. 1.0;
> 
> The smallest value N that satisfies the equation is 2.  But how can
> one represent 1.0 / 16.0 accurately in two decimal digits?
> [1.0 / 16.0 = 0.0625]
> 
> What am I missing here?

The point is that T'AFT digits is not guaranteed to be enough to
represent the values of type T.  (Consider

	type Fix is delta 1.0 / 3.0 range 0.0 .. 1.0;

No number of digits is sufficient!)  All you are guaranteed is that
the delta is >= (10 ** -T'AFT).

Now, what 'AFT is good for, I don't rightly know...  Any guesses,
campers?

Dale

Bryan@SIERRA.STANFORD.EDU (Doug Bryan) (09/24/86)

Dale brings up a few more interesting points concerning 'Aft.  Consider:

	type Fix is delta 1.0 / 3.0 range 0.0 .. 1.0;

Given the definition of Aft, Fix'Aft must return 1.  As Dale points out,
there is no way to exactly represent Fix'Delta in any finite number of digits.
It is interesting to note that Aft is defined in terms of delta, not small.
Thus Aft may not reflect the precision of the actual model numbers of the
type. (?)

Perhaps our question can more precisely be stated as follows:

        What was the rationale for defining Aft to return the smallest 
	positive integer N such that (10 ** N) * T'Delta >= 1?

Why was T'Small not used?  Surely T'Aft is not enough digits to precisely
display the decimal form of a model number of T. (We need
not even consider representation clauses.)  Is Aft sufficient digits
to display the model numbers of T such that one does not display the
same value more than once?

	type T is delta 1.0/16 range 0.0 .. 1.0;
	T'Aft = 2

let us look at some model numbers...

	0.0625	0.125	0.1875	0.25
	
If one were to print these model numbers using 
Put (X, Fore => 2, Aft => T'Aft, Exp => 0), we would see:

	0.06	0.12	0.18	0.25

No values are repeated.  Is this the intended use for 'Aft? 

Has anybody ever used 'Aft?  How  (campers) ?

doug and geoff
-------

stt@ada-uts (09/24/86)

T'AFT's primary purpose is as the default value for FIXED_IO.DEFAULT_AFT,
which determines how many digits after the decimal point PUT should
emit (by default, of course!).  See RM 14.3.8:2,6.