how to get percents from 2 numbers
#3

Yes, it does return 0 because inside the floatround function you have 3 integers, if you want to do that, you should use this
Quote:

floatround( float(num1)/num2 * 100);

now, num1 becomes a float, so you have at least one floating number in that operation, and it is enough. (when you divide a float with an int or vicevers the result it's a float, in your code you divide 2 integers, and the result is 0 if num1<num2)

BUT!

why not simply do this:
Quote:

new percents = num1*100 / num2;

?
Reply


Messages In This Thread
how to get percents from 2 numbers - by JustNothing - 26.12.2017, 16:12
Re: how to get percents from 2 numbers - by Lucases - 26.12.2017, 21:04
Re: how to get percents from 2 numbers - by GaByM - 26.12.2017, 21:20
Re: how to get percents from 2 numbers - by Lucases - 26.12.2017, 21:47
Re: how to get percents from 2 numbers - by JustNothing - 26.12.2017, 22:53

Forum Jump:


Users browsing this thread: 1 Guest(s)