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
SirChick
Forum Contributor
Posts: 125 Joined: Tue Jul 31, 2007 11:55 am
Post
by SirChick » Mon Sep 03, 2007 4:59 pm
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...
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Mon Sep 03, 2007 5:03 pm
[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 » Mon Sep 03, 2007 5:21 pm
explain that 1+ part i dont understand that bit :S
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Mon Sep 03, 2007 5:26 pm
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