Ver Mensaje Individual
  #1  
Antiguo 24-12-2006
Avatar de jorge1987
jorge1987 jorge1987 is offline
Miembro
 
Registrado: may 2005
Ubicación: Buenos Aires
Posts: 244
Reputación: 20
jorge1987 Va por buen camino
Ecuacion en Javascript a Delphi

Bueno, mi problema, es que tengo la siguiente ecuacion en JavaScript, y necesito convertirla a Delphi, hasta ahora, yo creo haberla echo bien, pero resulto que me tira un error de Float, y estoy medio perdido.

Funcion en JScript:

Código:
function Encode(str, fld,fld2) {
a=1846
b=1835
str=((a-b)*(str-a)^(str-b)>>a)<<b
if ((str==1737089024) && (fld==5 ) && (fld2==33) ){ alert("Perfecto");}
	else {alert("Que lástima por tí");}
}
Funcion Mia:

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
Var
  Aux : Real;
  suma : Integer;
  I : Integer;
  A, B : Integer;
  Aux2 : Integer;
begin
  Aux2 := 0;
  A := 1846;
  B := 1835;
  For I := 11111 To 99999 Do
    Begin
      Edit1.Text := IntToStr(I);
      //Suma := StrToInt(Edit1.Text[1]);
      Suma := (StrToInt(Edit1.Text[1])+StrToInt(Edit1.Text[2])+StrToInt(Edit1.Text[3])+StrToInt(Edit1.Text[4])+StrToInt(Edit1.Text[5]));
      If Suma = 33 Then
        Begin
          Try
            //Aux := exp((I-b) * ln((a-b)*(I-a)));
            Aux := exp((a-b)*(I-a) * ln((I-b)));
            Edit1.Text := FloatToStr(Aux);
            Edit1.Text := IntToStr(StrToInt(Edit1.Text) Shr A);
            //Aux2 := aux Shr a;
            //Aux := Shl(Aux2);
            Edit1.Text := IntToStr(StrToInt(Edit1.Text) Shl A);
            Aux2 := StrToInt(Edit1.Text);
            If Aux2 = 1737089024 Then
              //exp((I-b) * ln((a-b)*(I-a)))
              ListBox1.Items.Add(IntToStr(I));
          Except
            //ListBox1.Items.Add('no ' + IntToStr(I));
          End;
          //Aux := (Aux + 1)
        End;
    End;
 // Aux := exp(2 * ln(8));
 // Aux := Trunc(Aux);
 // Edit1.Text := FloatToStr(aux);

end;

Mi funcion es media precaria, porque intente mil maneras distintas.

Si no se entiende bien lo que hice, diganme, que intento limpiarla.

Saludos.
Responder Con Cita