Results 1 to 6 of 6

Thread: Just simple gp/hour for proggy

  1. #1
    Join Date
    Oct 2011
    Posts
    207
    Mentioned
    1 Post(s)
    Quoted
    20 Post(s)

    Default Just simple gp/hour for proggy

    Hello , i have this method for counting gp per hour for my proggy in script, but after some time it starts to show negative numbers instead of real gp/hour.

    Its working like 15-20minutes and then starts showing negative numbers.
    What could be wrong with it?

    here is part of proggy:
    Simba Code:
    WriteLn(' Money per Hour: ' +ToStr(((3600000*iTabsMade)/GetTimeRunning)*194));

  2. #2
    Join Date
    Dec 2011
    Posts
    392
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    What does iTabsMade look like? Since TimeRunning isn't negative that's the only place I'd think a negative could occur.

  3. #3
    Join Date
    Oct 2011
    Posts
    207
    Mentioned
    1 Post(s)
    Quoted
    20 Post(s)

    Default

    Quote Originally Posted by lilcmp1 View Post
    What does iTabsMade look like? Since TimeRunning isn't negative that's the only place I'd think a negative could occur.
    Well iTabsMade is used only once in the end of procedure make tabs , and in form

    Simba Code:
    iTabsMade:=iTabsMade+26;

    so I do not think that it could goes to negative.


    Not sure about TimeRunning and how it works.
    Last edited by djborec; 02-06-2012 at 12:59 AM.

  4. #4
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Default

    this should work:

    GPPH := Round((GP * 3600) / (GetTimeRunning / 1000));

  5. #5
    Join Date
    Nov 2011
    Posts
    1,532
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I will just explain why it wouldn't work with the first line.

    (3600000*iTabsMade)/GetTimeRunning)*194

    Math operations are calculated from left to right (unless overriden by parentheses).
    You got an numerical overflow from the first multiplication 3600000 * something, so it will show negative numbers.

    Nebula has shown one correct way of doing this. Divide one hour by gettimerunning first before multiplying your other params.

    When doing multiplication with large numbers, think about the magnitude you're dealing with before deciding the order of the operations.

  6. #6
    Join Date
    Oct 2011
    Posts
    207
    Mentioned
    1 Post(s)
    Quoted
    20 Post(s)

    Default

    Quote Originally Posted by nosaj.421 View Post
    I will just explain why it wouldn't work with the first line.

    (3600000*iTabsMade)/GetTimeRunning)*194

    Math operations are calculated from left to right (unless overriden by parentheses).
    You got an numerical overflow from the first multiplication 3600000 * something, so it will show negative numbers.

    Nebula has shown one correct way of doing this. Divide one hour by gettimerunning first before multiplying your other params.

    When doing multiplication with large numbers, think about the magnitude you're dealing with before deciding the order of the operations.
    Thanks . I thought there could be problem with that ,but I did not realize how big can be that number.

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
  •