SRL Archive - Other Scripts

IsPerfectSquare Function


driger1592

2006-04-30 15:42:48

Well, Kane could get away with posting weird functions, so I figured no one would mind me posting this ;)
Function IsPerfectSquare(e: extended): Boolean;
begin
If(e<0)Then
Exit;
If(Sqr(Trunc(Sqrt(e)))=e)Then
Result := True;
end;
This function checks if a number is a perfect square. You might find a use for this in a script. Who knows. It even works with negative numbers ;)

Pyro

2006-04-30 15:54:58

Lol but the sqrt of negative numbers is imaginary number. Just scar and most calculators just take the easy way out

driger1592

2006-04-30 16:06:28

Actually it causes a math error if I hadn't done

If(e<0)Then
Exit;

WhiteShadow

2006-04-30 21:21:26

From: driger1592
Actually it causes a math error if I hadn't done

If(e<0)Then
Exit;


Did you suddenly get high on math, from my quadratic idea?

:p , lol

driger1592

2006-04-30 21:55:55

High on math? Pft. You can't get high on math! *smokes math homework*

timmyboy

2006-04-30 22:02:20

From: driger1592
High on math? Pft. You can't get high on math! *smokes math homework*
Ewww…math paper smoke:p
Nice function, dunno how you could use it in a script =P

driger1592

2006-04-30 22:11:29

Well, if you ever want to know if something's a perfect square, this function does something to that affect ;)