How to get precents of a value?
#1

For example getting 15% of some numeric value. I saw servers doing that. How?
Reply
#2

Format Strings
Placeholder Meaning
%b Inserts a number at this position in binary radix
%c Inserts a single character.
%d Inserts an integer (whole) number
%f Inserts a floating point number.
%i Inserts an integer.
%s Inserts a string.
%x Inserts a number in hexadecimal notation.
%% Inserts the literal '%'

I've never seen that anywhere though
Reply
#3

The way i know:

part of amount : full amount x 100 = percent.

pawn Код:
24 / 153 * 100 = 15,7%
Reply
#4

I'll give you an example:
pawn Код:
new moneys, percent;

moneys = GetPlayerMoney(playerid)
percent = (moneys * 15) / 100
That's how you calculate 15 percent. If you want 7 percent (for example), replace 15 with 7.
Reply
#5

The Value you have divided by 100 and then multiplied by how much percent you want.
(Value / 100) * %

> You have 10,500 $
> You want it's 18%
> Use this: (10500/100) x 18
= 1,890$

> You have 1,457,811 $
> You want it's 56%
> Use: (1457811/100) x 56
= 816,374$

pawn Код:
stock ToPercentage(value, percentage)
{ return (value/100)*percentage; }

//Now you can use ToPercentage(5500, 15);
//It will return 15% of 5,500
Reply
#6

Thanks everybody. This can be locked / archived or w/e. No need in help anymore. Just math. Havent thought about it anyways thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)