how to assign values to complex constants

J. David Bryan dbryan at bcpl.net
Sun Oct 14 05:47:29 CEST 2001


On 12 Oct 2001, at 14:48, ZINTEL Gerhard wrote:

> I want to declare a complex constant in gpc like the following, non
> working example: 
> 
> const	I : complex = (0.0, 1.0);

You can declare this in Extended Pascal:

  const I = cmplx (0.0, 1.0);


> I have not found any example how to do this in the list archive or in the
> manual. 

The page titled "Complex Number Operations" in the GPC manual gives an 
example of the "cmplx" function.

 
> Is there a possibility to assign real values only to the real or
> imaginary parts of a variable especially to a function return value like
> in the following non working, sensless example: 
> 
> function add(a,b: complex):complex;
> begin
>   add.re := re(a) + re(b);
>   add.im := im(a) + im(b);
> end;

Again in Extended Pascal:

  function add (a, b: complex): complex;
    begin
      add := cmplx (re (a) + re (b), im (a) + im (b))
    end;

                                      -- Dave




More information about the Gpc mailing list