overkill, losing negative points?
I have a heavily modified version of the overkill version available on these forums, here is my overkill code, the problem with it is the new feature I added, when the numbers become too large, you beging to lose negative values, meaning you are getting points when you should be losing them.
PHP Code:
PHP Code:
I don't believe I have left out any majorly needed calls or functions or globals, but if you need more information please let me know so I can add it in hopes that I can get help with this, because I am stuck on this problem :/ |
Re: overkill, losing negative points?
I don't see any reference to "points." You should do some debuging and check the value of the "points" at several different points in the problem code. Then, when it shows something wrong (meaning not what you expected), you know where to look.
|
Re: overkill, losing negative points?
PHP Code:
edit: I know why, but I want to know how to fix the numbers from going whatever the integer limit may be (2147483647 ?) |
Re: overkill, losing negative points?
Quote:
Also, do you realize that that type of division is not the "normal" type of division? It's called integer division: E.g. 25/4 = 6 124/25 = 4 etc. |
Re: overkill, losing negative points?
I dont know of a better way of taking 25% of an integer properly, that would explain my math, and as for the limit, I plan on just setting a limit to the in32 limit, since many of my users have met and exceed that limit.
I will just have to rework my if and else ifs.. |
Re: overkill, losing negative points?
Quote:
If I calculated correctly, integer division is the same as float division but instead of rounding you use floor(). |
Re: overkill, losing negative points?
looks like ive over complicated things myself a little bit too, lol
thanks for the help fysiks. edit: one more question, if I want to make a check to see if it reaches the limit, should I check if its bigger than 2147483647, or should I check if it returns -1 ? |
Re: overkill, losing negative points?
Quote:
I'm sure there is a method of simulating an unsigned integer (which never goes negative) but I'm not sure that it is worth it. My best suggestion, however, is to modify how you calculate these "points" or whatever so that they don't gain them fast enough to reach such a limit. Another alternative would be to use a level system. When they reach a max value of "points" then you level them up and start the points over. So, the real point values would be calculated by (not literally): real_points = level * max_points_per_level + points This should make the real_points capable of reaching a max of (total_levels * max_points_per_level). |
All times are GMT -4. The time now is 17:55. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.