Comments and answers for "Why is this little bit of math returning infinity???"
http://answers.unity.com/questions/237997/why-is-this-little-bit-of-math-returning-infinity.html
The latest comments and answers for the question "Why is this little bit of math returning infinity???"Comment by Kleptomaniac on Kleptomaniac's answer
http://answers.unity.com/comments/238080/view.html
$$anonymous$$ake sure you're setting it up like so:
float yourFloat = 9.172421;
float newFloat = (yourFloat / 10) + yourFloat;
Haven't read how you've done it in the code so you may have to fit thi to how you've done it.Tue, 10 Apr 2012 17:02:07 GMTKleptomaniacComment by john-essy on john-essy's answer
http://answers.unity.com/comments/238070/view.html
Yea sorry kleptomaniac i was adding the 10% to the number i was given will edit my commentTue, 10 Apr 2012 16:45:34 GMTjohn-essyComment by Kleptomaniac on Kleptomaniac's answer
http://answers.unity.com/comments/238066/view.html
Well, I don't know what sort of maths you and your compiler are using because that equals none of those? It equals 0.9172421?Tue, 10 Apr 2012 16:42:53 GMTKleptomaniacComment by john-essy on john-essy's answer
http://answers.unity.com/comments/238063/view.html
That answer works great i realised i never initialized the barabrian variable but the problem now is the maths.
I got a random number of 9.172421 now if i divide this by 100 then * it by say ten it should return 10% which is 0.9172421 then add this to the value above gives me 10.0896631 but it doesn't it returns 9.264146 any ideas?Tue, 10 Apr 2012 16:39:55 GMTjohn-essyComment by Kryptos
http://answers.unity.com/comments/238027/view.html
Add this log before the division:
Debug.Log(barbarian.damageIncreaseWith2HWeapons);Tue, 10 Apr 2012 16:02:31 GMTKryptosComment by john-essy
http://answers.unity.com/comments/238021/view.html
Ok so all types are floats including the barabrian.damageIncreaseWith2HWeapons. Also this variable is modified within the inspector
So DamageInCreaseWith2HWeapons holds the value of 10.0f;
The dbugs are returning what they are meant to so when i first call the method i get something like 4.36526 but strait after the division occurs i get infinty.Tue, 10 Apr 2012 15:56:55 GMTjohn-essyAnswer by Kryptos
http://answers.unity.com/answers/238020/view.html
`Infinity` is returned when a DivisionByZero is performed (in most cases). Therefore you have to check the value of barbarian.damageIncreaseWith2HWeapons before attempting the division.
Something like:
if( barbarian.damageIncreaseWith2HWeapons > 0.1f )
{
l_Damage /= barbarian.damageIncreaseWith2HWeapons;
}Tue, 10 Apr 2012 15:55:09 GMTKryptosComment by Kleptomaniac
http://answers.unity.com/comments/238013/view.html
Also, what are all the Debug.Logs returning?Tue, 10 Apr 2012 15:50:29 GMTKleptomaniacComment by Kryptos
http://answers.unity.com/comments/238012/view.html
What are the types of your variables? Your code snippet doesn't show all useful informations that we need to help you.
Especially, what is the type of `barbarian.damageIncreaseWith2HWeapons`? How is this variable modified? What is the context of the call to `$$anonymous$$eleeDamage()`?Tue, 10 Apr 2012 15:49:28 GMTKryptos