Calculating percentages

Blitz3D Forums/Blitz3D Beginners Area/Calculating percentages

Cancerian(Posted 2005) [#1]
In my current game I am trying to create a summary page that tells the user the number of shots fired, number of enemies hit and then an accuracy percentage based on those values. Unfortunately, the method I use to do this doesn't seem to work in Blitz:

accuracy_percent# = enemies_hit / shots_fired

On any calculator an equation like 4 divided by 8 would result in .5 , or 50 percent. But Blitz always returns a zero when I attempt to do any calculations like this.

Any workarounds? Thanks.


Regular K(Posted 2005) [#2]
accuracy_percent#=float(enemies_hit)/float(shots_fired)

should work


Cancerian(Posted 2005) [#3]
Yup, works great! Thanks!