View Single Post
  #18 (permalink)  
Old 04-09-2012, 02:27 AM
Tim Prince
Guest
 
Posts: n/a
Default Re: specifying type of constant in floating-point initializationexpression

On 4/8/2012 10:28 AM, Richard Maine wrote:
> glen herrmannsfeldt<gah@ugcs.caltech.edu> wrote:
>
>> Phillip Helbig---undress to reply<helbig@astro.multiclothesvax.de> wrote:
>>> In article<jls1pv$crf$1@dont-email.me>, "James Van Buskirk" wrote:

>>
>> (snip)
>>>>>> DOUBLE PRECISION, PARAMETER :: A = 123456789

>>
>>>>> There are 9 significant digits here, which is more than
>>>>> a single precision quantity supports.

>>
>>>> But A will be defined correctly nonetheless.

>>
>>> Correct to DP or correct to SP? Some compilers make it
>>> correct to DP, but what does the standard guarantee?

>>
>> The integer constant should convert directly to double
>> precision without an intermediate single precision.

>
> Yes. Single precision is irrelevant here. There is no single precision
> in sight. I would expect this to be done exactly. If you are asking
> about guarantees, though, that's a different matter. The standard has
> pretty much no guarantees relating to the accuracy of floating point
> computations, including the computation involved in converting from
> integer. All the standard does is define the operation to be done. In
> this case, that operation is conversion from integer to double precision
> real.
>


Some of us have been wondering whether real(integervalue, kind(0d0))
should be required for accurate conversion in place of
dble(integervalue), as it seems to be with certain compilers.
Richard seems to be saying we might expect dble() to convert as
accurately, but we have "no guarantee."

--
Tim Prince
Reply With Quote