ID:173896
 
When I use a skill, I have a procedure raise the skill. It is exactly

skill += 1

But, sometimes when the skill raises, it raises by an odd amount. For example, it will go from 24.0 to 25.0001. Anybody encountered anything like this before?

Thanks
Gynax wrote:
When I use a skill, I have a procedure raise the skill. It is exactly

skill += 1

But, sometimes when the skill raises, it raises by an odd amount. For example, it will go from 24.0 to 25.0001. Anybody encountered anything like this before?

Thanks

nope but maybe try

skill += 0.9
When I use a skill, I have a procedure raise the skill. It is exactly

skill += 1

But, sometimes when the skill raises, it raises by an odd amount. For example, it will go from 24.0 to 25.0001. Anybody encountered anything like this before?

As far as know there is real poor precision when handling floating point math in BYOND. I haven't had any problems like this when dealing strictly with integers, so do you add fractional amounts in other areas? If you need too you can just chop off the error by useing round() to round off all but what you want to show/use.
Theodis has you on the right track. Something is wrong with a calcuation somewhere that you're getting fractional values appearing in your math. Probably you're doing multiplication or division and it's just not precise enough. The solution is to use round(n,1) on the result whenever you do those sorts of calculations, so the value remains an integer. Adding or multiplying integers doesn't have that problem, but with division you can end up with a few snags. Other operations like square roots and raising values to an exponent will also tend to screw up that way.

As an example of this, try dividing 1 by 7 on a typical calculator, then multiplying by 7. The result will usually be just over or just under 1.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
As an example of this, try dividing 1 by 7 on a typical calculator, then multiplying by 7. The result will usually be just over or just under 1.

Unless it's a fancy scientific calculator like the one I usually use. =) Usually you have to get a cheap and nasty pocket calculator (the type that doesn't even have a square root button) to get that effect.