Jump to content

No Floating Numbers After Division


mobone
 Share

Recommended Posts

I need the win to loss ratio, but its not returning anything after the decimal. I'm sure its an easy solution but I can't seem to figure it out.Battles won and battles lost are both integers.

	settype($battles_won, "float");	settype($battles_lost, "float");	settype($winloss, "float");		$winloss = $battles_lost/$battles_won;

I've tried rounding the division also.

Link to comment
Share on other sites

I think php refers to them as doubles and not floats, as JavaScript does.

Link to comment
Share on other sites

The variables are not floats, they're ints, but I thought the settype would change them to floats.
It will, but they're still going to have their integer values. Converting an int to a float is going to result in the same value. If you convert 8 to a float, you'll get 8.0.
var_dump($battles_lost);var_dump($battles_won);$winloss = $battles_lost/$battles_won;var_dump($winloss);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...