On Tue, Jun 6, 2017 at 3:41 AM, W. J. Metzger <[log in to unmask]> wrote:
> However, REAL(c) with c complex returns the real value of c with the
> kind of c. Thus if c is double precision complex, real returns a double
> precision real. Thus it seems not unreasonable to expect CMPLX(x, y) to
> return a complex with the kind of x.
>
> Admittedly, this might break some programs.
>
> Cheers, Wes
> ..
It is confusing and confounding, saying the least, to read the
description of REAL function in the standard and notice the exception
made for the case where the actual argument is of type complex:
-- Text from J3/10-007r1 WD 1539-1 2010-11-24 --
13.7.138 REAL (A [, KIND])
1 Description. Conversion to real type.
2 Class. Elemental function.
3 Arguments.
A shall be of type integer, real, or complex, or a boz-literal-constant .
KIND (optional) shall be a scalar integer constant expression.
4 Result Characteristics. Real.
Case (i): If A is of type integer or real and KIND is present, the
kind type parameter is that specified by the
value of KIND. If A is of type integer or real and
KIND is not present, the kind type parameter is
that of default real kind.
Case (ii): If A is of type complex and KIND is present, the kind
type parameter is that specified by the value
of KIND. If A is of type complex and KIND is not
present, the kind type parameter is the kind
type parameter of A.
Case (iii): If A is a boz-literal-constant and KIND is present, the
kind type parameter is that specified by the
value of KIND. If A is a boz-literal-constant and
KIND is not present, the kind type parameter is
that of default real kind.
5 Result Value.
Case (i): If A is of type integer or real, the result is equal to a
processor-dependent approximation to A.
Case (ii): If A is of type complex, the result is equal to a
processor-dependent approximation to the real part
of A.
Case (iii): If A is a boz-literal-constant , the value of the result
is the value whose internal representation as
a bit sequence is the same as that of A as modi ed
by padding or truncation according to 13.3.3.
The interpretation of the bit sequence is processor dependent.
6 Examples. REAL (-3) has the value -3.0. REAL (Z) has the same kind
type parameter and the same value
as the real part of the complex variable Z.
-- End Text --
The bit about, "If A is of type complex and KIND is not present, the
kind type parameter is the kind type parameter of A" appears
inapropos: given the premise of a type conversion function,
* why can it not be, "if KIND is not present, the kind type parameter
is that of default real kind"?
* with the result being, "equal to a processor-dependent
approximation" of A (or its relevant part or bit sequence as
applicable) for all types of allowed arguments of A to the REAL
function, be it integer, real, complex, of boz-literal-constant.
Thanks,
Vipul Parekh
|