% calculation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SirChick
Forum Contributor
Posts: 125
Joined: Tue Jul 31, 2007 11:55 am

% calculation

Post by SirChick »

How do u structure a sentence so say you had:

$value: 10
$percentage : 2

So i want to get 2% of 10 then add that % on to 10...
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

;)
[math]
new_value = old_value * (1 + percentage/100)
[/math]
There are 10 types of people in this world, those who understand binary and those who don't
SirChick
Forum Contributor
Posts: 125
Joined: Tue Jul 31, 2007 11:55 am

Post by SirChick »

explain that 1+ part i dont understand that bit :S
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

100% = 1

1 + (2%) = 100% + 2% = 102%

102% = 1.02 = 1 + 0.02 = 1 + 2/100
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply