Jump to content
  • 0

Overflow detected! Banker script


Feistz

Question


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  139
  • Reputation:   10
  • Joined:  11/10/11
  • Last Seen:  

Td80U.png

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

Link to comment
Share on other sites

10 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  130
  • Reputation:   43
  • Joined:  12/11/11
  • Last Seen:  

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 by plankt
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  139
  • Reputation:   10
  • Joined:  11/10/11
  • Last Seen:  

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?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  554
  • Reputation:   70
  • Joined:  04/04/12
  • Last Seen:  

what is your server's maximum zeny??

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  139
  • Reputation:   10
  • Joined:  11/10/11
  • Last Seen:  

2 billion. I believe that is the max amount you can set in rAthena right?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  554
  • Reputation:   70
  • Joined:  04/04/12
  • Last Seen:  

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....

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  139
  • Reputation:   10
  • Joined:  11/10/11
  • Last Seen:  

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?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  554
  • Reputation:   70
  • Joined:  04/04/12
  • Last Seen:  

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....

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

@malufett: That wouldn't work, you'd get an overflow error before the check occurs. o:

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  554
  • Reputation:   70
  • Joined:  04/04/12
  • Last Seen:  

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....

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  139
  • Reputation:   10
  • Joined:  11/10/11
  • Last Seen:  

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...