# overflow error for small numbers

[b][red]This message was edited by cloudncali at 2006-6-16 20:29:50[/red][/b][hr]
ok i have some vary small numbers like not even in the hundreds

is there any other way this error is caused?
any way help plz

• : [b][red]This message was edited by cloudncali at 2006-6-16 20:29:50[/red][/b][hr]
: ok i have some vary small numbers like not even in the hundreds
:
: is there any other way this error is caused?
: any way help plz
:
:
:
Hello any one want to help me
• [b][red]This message was edited by BitByBit_Thor at 2006-6-19 5:29:34[/red][/b][hr]
: : [b][red]This message was edited by cloudncali at 2006-6-16 20:29:50[/red][/b][hr]
: : ok i have some vary small numbers like not even in the hundreds
: :
: : is there any other way this error is caused?
: : any way help plz
: :
: :
: :
: Hello any one want to help me
:

Post the piece of code.

Best Regards,
Richard

• Public HP As Single
Public HPM As Single
Public MP As Single
Public MPM As Single
Public SP As Single
Public SPM As Single
HPBar.Width = 2520 - (HP / HPM)
MPBar.Width = 2520 - (MP / MPM)
SPBar.Width = 2520 - (SP / SPM)

im gussing that it might be the /ing Part
• : Public HP As Single
: Public HPM As Single
: Public MP As Single
: Public MPM As Single
: Public SP As Single
: Public SPM As Single
: HPBar.Width = 2520 - (HP / HPM)
: MPBar.Width = 2520 - (MP / MPM)
: SPBar.Width = 2520 - (SP / SPM)
:
: im gussing that it might be the /ing Part
:

you can try declaring the variables as Double instead of Single, that would provide some additional math precision. still may not solve the overflow because of how the floating point numbers are represented in binary.
• : : Public HP As Single
: : Public HPM As Single
: : Public MP As Single
: : Public MPM As Single
: : Public SP As Single
: : Public SPM As Single
: : HPBar.Width = 2520 - (HP / HPM)
: : MPBar.Width = 2520 - (MP / MPM)
: : SPBar.Width = 2520 - (SP / SPM)
: :
: : im gussing that it might be the /ing Part
: :
:
: you can try declaring the variables as Double instead of Single, that would provide some additional math precision. still may not solve the overflow because of how the floating point numbers are represented in binary.
:
i did that and it i still got the error i rilly need to solve this this is holding back my game
• : : : Public HP As Single
: : : Public HPM As Single
: : : Public MP As Single
: : : Public MPM As Single
: : : Public SP As Single
: : : Public SPM As Single
: : : HPBar.Width = 2520 - (HP / HPM)
: : : MPBar.Width = 2520 - (MP / MPM)
: : : SPBar.Width = 2520 - (SP / SPM)
: : :
: : : im gussing that it might be the /ing Part
: : :
: :
: : you can try declaring the variables as Double instead of Single, that would provide some additional math precision. still may not solve the overflow because of how the floating point numbers are represented in binary.
: :
: i did that and it i still got the error i rilly need to solve this this is holding back my game
:

Did you make sure that HPM, MPM and SPM have a value? Division by zero will cause it's own kind of overflow error (or was it just a 'division by zero' error?)

Furtherly, run through the code with Debug, step by step. Make sure the value of Width etc doesn't get negative! Running through it in debug will let you see what values come out of the equation.

Best Regards,
Richard

• [b][red]This message was edited by DrMarten at 2006-6-20 0:58:59[/red][/b][hr]
Hi,

What are HPBar MPBar and SPBar are they scrollBars?

The VB name for the control is a Trackbar.
It is in VB.Net at least.

Regards,

Dr M.

• : : : : Public HP As Single
: : : : Public HPM As Single
: : : : Public MP As Single
: : : : Public MPM As Single
: : : : Public SP As Single
: : : : Public SPM As Single
: : : : HPBar.Width = 2520 - (HP / HPM)
: : : : MPBar.Width = 2520 - (MP / MPM)
: : : : SPBar.Width = 2520 - (SP / SPM)
: : : :
: : : : im gussing that it might be the /ing Part
: : : :
: : :
: : : you can try declaring the variables as Double instead of Single, that would provide some additional math precision. still may not solve the overflow because of how the floating point numbers are represented in binary.
: : :
: : i did that and it i still got the error i rilly need to solve this this is holding back my game
: :
:
: Did you make sure that HPM, MPM and SPM have a value? Division by zero will cause it's own kind of overflow error (or was it just a 'division by zero' error?)
:
: Furtherly, run through the code with Debug, step by step. Make sure the value of Width etc doesn't get negative! Running through it in debug will let you see what values come out of the equation.
:
:
: Best Regards,
: Richard
:
:

Overflow can be caused by how the numbers are represented in binary. Some floating point numbers can *never* be accurately represented, ie: 1/3 is not equal to 0.33333333 and there is a sign bit for floating point. arithmetic operations can introduce their own error.

i have a good article by a professor from drexel but its no longer on the web, there are others - http://docs.python.org/tut/node16.html

errors occur from-
- inexact representation of a constant
- integer overflow resulting from a calculation with a result too large for the wordsize
- integer overflow resulting from a calculation with a result too large for the number of bits used to represent the mantissa of a floating point number
- accumulated error resulting from repeated use of numbers stored inexactly