Im trying to figure out how to represent a complex number in the ada programming language. Through research I figured out about the with Ada.Numerics.Complex_Types package and looking at the package I dont see how the imaginary number 'i' is represented. Can someone please explain?
You can represent 2+6i as (2.0, 6.0).
with Ada.Numerics.Generic_Complex_Types;
procedure Cplx is
type My_Real is digits 15; -- Double precision
package RC is new Ada.Numerics.Generic_Complex_Types (My_Real);
use RC;
c: Complex;
begin
c.Re := 2.0;
c.Im := 6.0;
-- More compact:
c := (Re => 2.0, Im => 6.0);
-- Even more compact:
c := (2.0, 6.0);
end;