0

How can I calculate the square root of a number in Inno Setup?

4
  • Inno Setup is for installing software. Why would you need to calculate square root using it? It supports things that are done during software installation, and allows some extension with its scripting support. I see no reason it would calculate SQR, because there's no reason (at least that I can see) to do that with a software installer.
    – Ken White
    May 25, 2013 at 21:30
  • I have a simple serial check that uses Sqrt validation. I need to implement in Inno Setup routine validation. May 26, 2013 at 0:44
  • Resolvido: recorre := 144; for I := 0 to 9 do begin recorre := recorre / 2 + 144 / (2 * recorre); end; May 26, 2013 at 1:15
  • 1
    You should add more information (the rest of the scripting code) and post it as an answer to the question. That's allowed here. :-) You can even accept it as the correct solution after a period of time.
    – Ken White
    May 26, 2013 at 1:23

1 Answer 1

4

After studying a bit the field of mathematics, could do the calculation.

//Sqtr calc
Function SqtrCalc(n : Single) : Single;
Var
  I: Integer;
  y: Single;
Begin
  y := n;  

  for I := 0 to 9 do
    begin
      y := y / 2 + n / (2 * y);
    end;

  Result := y;
End;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.