Feistz Posted July 9, 2012 Posted July 9, 2012 Got this error in a Bank script in my server. This error pops up whenever i choose to withdraw or deposit zeny. Can someone help me on this? bank.txt Quote
plankt Posted July 9, 2012 Posted July 9, 2012 (edited) The error itself in english: Warning. Overflow detected when using addition on the two values, 2147483647 and 21474836. As Wikipedia explains overflow: Arithmetic overflow, a condition that occurs when a calculation produces a result that is greater than what a given register can store or represent With the first value being the greatest positive value a signed integer can store, the result of the addition is greater then what a signed integer can store. My guess is that when the script calculates the interest, it doesn't check if the value will overflow or not. I don't remember how the emulator works with overflowing values, but do you get a negative bank value if you deposit more money? Edited July 9, 2012 by plankt Quote
Feistz Posted July 10, 2012 Author Posted July 10, 2012 The error itself in english: Warning. Overflow detected when using addition on the two values, 2147483647 and 21474836. As Wikipedia explains overflow: Arithmetic overflow, a condition that occurs when a calculation produces a result that is greater than what a given register can store or represent With the first value being the greatest positive value a signed integer can store, the result of the addition is greater then what a signed integer can store. My guess is that when the script calculates the interest, it doesn't check if the value will overflow or not. I don't remember how the emulator works with overflowing values, but do you get a neegative bank value if you dposit more money? Thanks for the reply, unfortunately, i cannot test it because whenever i want to deposit or withdraw money, the NPC will stuck BUMP! Can someone fix this script and error for me? Quote
Feistz Posted July 10, 2012 Author Posted July 10, 2012 2 billion. I believe that is the max amount you can set in rAthena right? Quote
malufett Posted July 10, 2012 Posted July 10, 2012 yes it can.... up to INT_MAX(2147483647) however your script doesn't check if the variable is going to be over the max value when the interest is added.... therefore you must add the max checking.... Quote
Feistz Posted July 10, 2012 Author Posted July 10, 2012 yes it can.... up to INT_MAX(2147483647) however your script doesn't check if the variable is going to be over the max value when the interest is added.... therefore you must add the max checking.... how can i exactly add this checking? can you modify the script for me? Quote
malufett Posted July 10, 2012 Posted July 10, 2012 sorry but I can't modify the script ATM... but try this if( #3rdbank > 2147483647 ) set #3rdbank, 2147483647; add this after the adding of interest.... Quote
Euphy Posted July 10, 2012 Posted July 10, 2012 @malufett: That wouldn't work, you'd get an overflow error before the check occurs. o: Quote
malufett Posted July 10, 2012 Posted July 10, 2012 oh...yeah..it must be if( (#3rdbank+@int) > 2147483647 ) set #3rdbank, 2147483647; just add before the adding and skip the adding when this is set to true... thanks Euphy.... Quote
Feistz Posted July 10, 2012 Author Posted July 10, 2012 oh...yeah..it must be if( (#3rdbank+@int) > 2147483647 ) set #3rdbank, 2147483647; just add before the adding and skip the adding when this is set to true... thanks Euphy.... oh...yeah..it must be if( (#3rdbank+@int) > 2147483647 ) set #3rdbank, 2147483647; just add before the adding and skip the adding when this is set to true... thanks Euphy.... Which part of script do I need to add this exactly? Quote
Question
Feistz
Got this error in a Bank script in my server. This error pops up whenever i choose to withdraw or deposit zeny. Can someone help me on this?
bank.txt
10 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.