Results 1 to 4 of 4

Thread: PowerOf (math.scar)

  1. #1
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default PowerOf (math.scar)

    I was trying to use the ^ symbol for doing powers, but it never seemed to work in Simba (not sure whether Simba has a different way of doing indices, my computer [those it happens both on my laptop and my desktop], or there is no function existance for indices). So I created a little mini powers function. It's nothing special, and I'm guessing loads of people have created one for use in their scripts, but here it is for people who might wish to use it:

    SCAR Code:
    function PowerOf(int, power: integer): integer;
    var
    i: integer;
    begin
      Result := int;
      for i := 1 to power - 1 do
        Result := Result * int;
    end;

    This can't deal with negative or fractional indices, I'll update this when I've created one (probably named PowerOfEx).

    If there is actually a way of doing this currently, I'd love to know!

  2. #2
    Join Date
    Feb 2009
    Location
    AZ, USA
    Posts
    460
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    pow(base: Extended; exponent: Extended): Extended
    Is your account in an old-school random? Help SRL-OSR solve randoms!

  3. #3
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Too bad we cant just do
    Simba Code:
    program new;

    operator^(Param1, Param2: extended): extended;
    begin
      Result := Pow(Param1, Param2);
    end;

    begin
      WriteLn(2 ^ 2);
    end.

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  4. #4
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    ^ refers to a pointer type PASCAL. Also, in C and other languages, ^ is bitwise exclusive-OR.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

Thread Information

Users Browsing this Thread

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

Posting Permissions

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