Hey!
Short question: In a damage formula, is 1 + 0.1 = 1.1 or 1? I could imagine that the initial integer makes the result an integer, too, instead of a float, so I would need 1.0 + 0.1 if I want 1.1 as the result. Just wanted to make sure. 🙂
The default damage calculation boxes puts everything to integers, I believe. You can set it to decimals by adding the "to float" expression at the end of the formula, I think.
Why not test it and see?
Anyway, I'm pretty sure it would come out as a float.
I believe if you're only going to display int's, all final calculations should be integers.
Don't store the HP as a float and then display it as an integer.
No one expects to deal 0 damage and then still lose HP.
What about this example:
Damage = (1 + 0.1) * 100
(Let's assume those numbers come from variables, because otherwise it doesn't make any sense to write it like this, of course.)
Is the damage then 100 or 110?
That was my question. But now that I wrote down this example, I guess it's not that hard to just test it myself. 😀 So, thank you anyway!
If you're asking how ruby does its math, it doesn't automatically round things unless you're dealing with division.
Yep, that's what my testing results told me, too. 🙂 Thank you nonetheless. I just could have imagined you had to tell Ruby whether you want to use integers or floats, I thought I read/heard that once.
Having one of the numbers be a float is telling it the result should be a float.