Results 1 to 10 of 10

Thread: AverageIntegerArray

  1. #1
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default AverageIntegerArray

    if this was ported to delphi and into wizzypluggin it might be nice...

    SCAR Code:
    Function AverageIntegerArray(TIA: TIntegerArray): integer;
    var
      i, t :integer;
    begin
      t := High(TIA);
      for i := 0 to t do
        Result := Result + TIA[i];

      Result := Round(Result / Length(TIA));
    end;

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  2. #2
    Join Date
    Mar 2007
    Posts
    1,700
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Added, thanks.

  3. #3
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Lmao, I made one of these a while ago. It's like... 17 lines long xD.

    ~Sandstorm

  4. #4
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Also added AverageExtended
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  5. #5
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Does SCAR truncate integers after division? If so, you probably wouldn't need Round in there at all.

    EDIT: Nevermind, I'm tired.
    Last edited by Method; 04-26-2009 at 02:20 PM.
    :-)

  6. #6
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Quote Originally Posted by Method View Post
    Does SCAR truncate integers after division? If so, you probably wouldn't need Round in there at all.
    Truncation is different from rounding. To demonstrate, run this:
    SCAR Code:
    program New;
    begin
    Writeln(IntToStr(Round(6.55)));
    Writeln(IntToStr(655/100));
    end.

  7. #7
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Oh, whoops. I probably should get some sleep, considering this has happened multiple times recently.
    :-)

  8. #8
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    In the day you didn't get functions to SRL like that :<

    http://www.villavu.com/forum/showthread.php?t=2104

  9. #9
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Yeah, seems that he is a mod so he gets to do that

  10. #10
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Getting off topic... closed.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

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
  •