Working out percentages and stuff.
#1

Hi, im really confused with working out percentages.

This is what i've tried so far, but went horrible wrong.

pawn Код:
new percent = 3; //3 percent

new Float:earned = PropData[propertyid][p_Sell] - ((PropData[propertyid][p_Sell] / 100.0) * percent);
I end up getting some crazy long number.. Can someone help with this please?
Reply
#2

hmm, i'll check this out. i'll edit this post

pawn Код:
new float:proc = 0.97; // note that this will be equal to the amount remaining ;]
new earned = floatround(PropDate[propertyid][p_Sell]*proc); // this will round the float. there may be a slight miscalculation at some points for example *.5 at the end would lead it would be *+1 instead of *1, but tat's nothing to worry about. this should work. wtf am I writing so long anyway? :DD
Reply
#3

Код:
forward Percent(Float:number, Float:percentage);
Код:
stock Percent(Float:number, Float:percentage) {
new Float:Sum;
Sum = (number/100)*percentage;
return floatround(Sum);
}
Код:
new wages = Percent(number,percentage);
Reply
#4

Thanks guys, helped a lot. I've got it working perfect now.

Again thanks for your time and replies
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)