[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
function Abs (i: integer type): integer type; |
function Abs (x: real type): real type; |
function Abs (z: Complex type): real type; |
Returns the absolute value of the argument. For integer or real values of `x', the definition is
function Abs (x: integer or real type): integer or real type; begin if x < 0 then Abs := -x else Abs := x end; |
whereas for complex values it is
function Abs (x: Complex): Real; begin Abs := SqRt (x * Conjugate (x)) end; |
The function `Abs' is defined in ISO-7185 Pascal; its application to complex values is defined in ISO-10206 Extended Pascal.
program AbsDemo; var i1: Complex; begin WriteLn (Abs (42)); { 42 } WriteLn (Abs (-42)); { 42 } WriteLn (Abs (-12.1) : 0 : 1); { 12.1 } i1 := Cmplx (1, 1); { 1 + i } WriteLn (Abs (i1) : 0 : 3) { 1.414, i.e. SqRt (2) } end. |
section 9.260 Sqr.