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

 

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.