Jump to content

Curently using decimal point for percent, how can I use the percent sign?


chinwan

Recommended Posts

I have a script that is calculating how much the credit card fee was to process a payment.

I am going to be use relatively fixed values for the credit card percent.

 

As of now, I have the percent written as a decimal point (".275") , but I would rather have it as a "2.75%". How would I restructure my statement:

$creditcardpercent = ".275"

$balance = $order * $creditcardpercent

 

That it will calculate it properly?

 

 

Thanks

 

You cannot use like

$per = 5.35% because the per cent sign is a modulus operator.

 

$creditcardpercent = .275 *100;
$balance = $order * $creditcardpercent;

// or
$creditcardpercent = .275;
$balance = $order * ($creditcardpercent * 100);

Perhaps I misunderstood you. Of course you not user "2.75%" in calculations and you must not store the value that way in the database but you may display if on your pages in any format you wish. Whether you store it as 2.75 or 0.0275 doesn't really matter, you can do format them in anyway you like when producing html output.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.