By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,968 Members | 1,684 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,968 IT Pros & Developers. It's quick & easy.

How to take off a percentage?

100+
P: 133
Hi,

I have the following values:

49.99
99.99
149.99
199.99

People can enter a coupon code to take away e.g. 10, 20, 30%

How would i take away one of the above percentages away from e.g. 199.99

Cheers,
Adam
Feb 26 '08 #1
Share this Question
Share on Google+
4 Replies


hsriat
Expert 100+
P: 1,654
Hi,

I have the following values:

49.99
99.99
149.99
199.99

People can enter a coupon code to take away e.g. 10, 20, 30%

How would i take away one of the above percentages away from e.g. 199.99

Cheers,
Adam
10% of 199.99 = 199.99*(10/100) = 19.999

Are you asking this or something else?
Feb 26 '08 #2

100+
P: 133
10% of 199.99 = 199.99*(10/100) = 19.999

Are you asking this or something else?

Yes thanks but what i need it to is e.g.

If i do this

$total = 199.99;
$maintotal = $total*(50/100);

Then i get back 75 but what i need back is 74.99

Any ideas?
Feb 26 '08 #3

hsriat
Expert 100+
P: 1,654
Yes thanks but what i need it to is e.g.

If i do this

$total = 199.99;
$maintotal = $total*(50/100);

Then i get back 75 but what i need back is 74.99

Any ideas?
I think there's something wrong with server that it gives 75 when you process the above said equation.

A function known as round() is used, but to convert 74.99 to 75, not the other way.

You may tell more detail about the problem, then I can help you.
Feb 26 '08 #4

ronverdonk
Expert 2.5K+
P: 4,258
There is definitely something wrong. The following results 99.995[php]<?php
echo 199.99*(50/100);
//result = 99.995
?>[/php]Ronald
Feb 26 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.