Criar funções isFloat e isInteger sem usar Exception
Apreenda a criar duas funções para validar se determinado valor é inteiro ou float, sem usar bloco try except.
var
temp, errorPos :integer;
begin
Val(Value, temp, errorPos);
if errorPos = 0 then
result :=(temp-round(temp))=0;
end;
function IsFloat(value:variant):Boolean;
var
temp, errorPos :integer;
begin
Val(Value, temp, errorPos);
result := (errorPos = 0);
end;
var
temp, errorPos :integer;
begin
Val(Value, temp, errorPos);
result := (errorPos = 0);
end;
Artigos relacionados
-
Artigo
-
Artigo
-
Artigo
-
Artigo
-
Artigo