(j3.2006) (SC22WG5.5410) J3 Fortran interp letter ballot #32 revised - due9-Jan-2015

Malcolm Cohen malcolm
Mon Jan 12 04:23:18 EST 2015


Robert Corbett writes:
>----------------------------------------------------------------------
>F08/0123 N
>
>The results of applying the intrinsic functions SPACING and RRSPACING
>to subnormal values were the subject of interpretation F03/0055.  A
>copy of that interpretation appears below.  Interpretation F03/0055
>included edits that were incorporated in the Fortran 2008 standard.

However that interp is not about the same topic (as this interp).  F03/0055 
is purely and simply about which model number to return the information for 
when the argument is not itself a model number.  This (obviously) affects 
subnormals, but also affects other number systems such as double-double 
precision.

It has no bearing on this question whatsoever.

>The proposed revised specification for the intrinsic function SPACING
>and the existing text are equivalent if the value of e\sub{min} is
>chosen properly for the KIND of real value.

That is not true.

>  The text that F03/0055
>added assumes that the value of e\sub{min} for a processor that
>supports subnormal numbers is the exponent of the smallest positive
>representable number.

That is not true, and it is clear from the text of F03/0055 that none of the 
questioners and answerers thought such a thing!  I quote the question:
  "What results do SPACING and RRSPACING return if the value of X lies 
outside the model of 13.4, in particular if it is denormal?"

This question would have no meaning if subnormal numbers were model numbers.

>  The Fortran 2008 standard does not spell out
>how the value of e\sub{min} is to be chosen,

Yes, we are expecting the vendor to do the "right thing".

The "reasonable" (perhaps naive) expectation is that it will be chosen to be 
the most negative number for which all model numbers are machine numbers, 
and for which arithmetic (on model numbers) works correctly.  The latter 
consideration is pretty much moot these days, assuming correctly-functioning 
hardware, since conformance to IEEE arithmetic requires this and much more.

Whether subnormal numbers exist does not affect this value, since the 
including the exponent values of subnormal numbers in the model would result 
in MANY model numbers which would not be representable.  That is, rather 
obviously, not a reasonable result!

> which must be
>addressed if the results of the intrinsic function SPACING are to be
>fully specified.

The results of the intrinsic function SPACING ***ARE*** fully specified.  It 
returns the spacing of model numbers.  That model numbers are not themselves 
fully specified by the standard is completely irrelevant.

>If a different value of e\sub{min} is chosen, the result of SPACING
>for the value 0.0 becomes problematic.  For example, if the value
>of e\sub{min} is chosen to be -126 for IEEE single-precision, the
>value of SPACING(0.0) will be 1.1754944E-38, while the value of
>SPACING(X) for a nonzero subnormal value will be 1.4012985E-45.
>SPACING(0.0) should not be greater than SPACING(X).

That is just completely and utterly wrong.  The fact is that the spacing of 
*normal* model numbers between TINY and 2*TINY is much much smaller than the 
spacing of model numbers around zero.  In fact for single precision the 
spacing of model numbers is less than TINY in the range TINY to TINY*2**23 
i.e. quite a large range, and for double precision an even bigger range.

When we added an intrinsic to return the spacing of model numbers, we 
specified (and expected!) it to return the spacing of model numbers, or a 
reasonable approximation if the exact spacing of the model numbers in 
question was not representable (as it is for smallish numbers when 
subnormals are not available).  When subnormals are available, they are 
unsuitable (as explained above) to be model numbers, but they happen to be 
ideally suited to returning the actual spacing of small numbers.

Van Snyder writes:
>I agree with Bob Corbett that spacing(0.0) ought not be greater than
>spacing(X) when X is submormal.

(a) that does not appear to be what Bob Corbett is saying;
(b) this interp is not addressing the issue of which spacing to return when 
the argument is not a model number (the topic of F03/0055).

I have some sympathy with the argument that F03/0055 gives the wrong 
specification when X is not a model number; one might have thought that when 
X is not a model number, it is in between two model numbers, ***And 
Therefore The Spacing It Returns Should Be The Space Between Those Model 
Numbers***!  However, that is not what we decided for F03/0055.  Again, 
F03/0055 is not just about subnormals... (though that's probably where most 
would see the effects).

I have no objection at all to revisiting F03/0055, but I don't see why we 
have to do that before answering this interp.  (There are at least three 
plausible - maybe even reasonable - choices of algorithm for deciding which 
model number to return the spacing for...)

Cheers,
-- 
...............................Malcolm supposedly still on holiday.




More information about the J3 mailing list