Results 1 to 7 of 7

Thread: IsPerfectSquare Function

  1. #1
    Join Date
    Feb 2006
    Location
    Wisconsin (like farm-town, USA) :P
    Posts
    254
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default IsPerfectSquare Function

    Well, Kane could get away with posting weird functions, so I figured no one would mind me posting this
    Code:
    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

  2. #2
    Join Date
    Feb 2006
    Location
    New Zealand
    Posts
    1,330
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

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

  3. #3
    Join Date
    Feb 2006
    Location
    Wisconsin (like farm-town, USA) :P
    Posts
    254
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

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

    If(e<0)Then
    Exit;

  4. #4
    Join Date
    Feb 2006
    Location
    L.A, USA
    Posts
    1,632
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by 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?

    , lol

  5. #5
    Join Date
    Feb 2006
    Location
    Wisconsin (like farm-town, USA) :P
    Posts
    254
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

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

  6. #6
    Join Date
    Mar 2006
    Location
    Igloo #201702,Canada
    Posts
    188
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

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


    ^ My next tutorial will teach you how to make this ^

  7. #7
    Join Date
    Feb 2006
    Location
    Wisconsin (like farm-town, USA) :P
    Posts
    254
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 02-27-2008, 05:20 PM
  2. Replies: 2
    Last Post: 02-26-2008, 08:26 PM
  3. My First Function ^^
    By Naike in forum Research & Development Lounge
    Replies: 8
    Last Post: 02-13-2008, 07:17 PM
  4. [FUNCTION] FindDoorColour: integer; By ZephyrsFury [FUNCTION]
    By ZephyrsFury in forum Research & Development Lounge
    Replies: 10
    Last Post: 07-27-2007, 08:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •