Código: Seleccionar todo
function AbsoluteValue(X:Real):Real;
const
ZeroValue = 0.0;
begin
if X < ZeroValue then
Result := -X (* Es igual a X * (-1) *)
else if X > ZeroValue then
Result := X
else
Result := ZeroValue;
end;
Código: Seleccionar todo
function AbsoluteValue(X:Real):Real;
const
ZeroValue = 0.0;
begin
if X < ZeroValue then
Result := -X (* Es igual a X * (-1) *)
else if X > ZeroValue then
Result := X
else
Result := ZeroValue;
end;