I'm building an ecommerce site integrated with paypal.
We take multiple currencies, so I want to make sure that (for accounting reasons) i'm correctly performing any math for currency conversion.
After multiplying the currency conversion * the original currency, I always end up with lots of trailing numbers after the decimal point.
Is there a standard way to do this? Should I truncate or round? Do I need to round multiple times in case rounding the 1/1000 decimal will affect rounding the 1/100 decimal?
Should I be doing something like:
Math.Round(Math.Round(x, 3), 2)
I've been having trouble finding good information about how this is done (hopefully US and Europe are the same).
Log into your PayPal account. Go to your Wallet page. Click the Options icon beside the currency you want to convert which is USD. Click Convert currency.
Via PayPal: Always click "See currency options" and pay in the seller's currency to avoid the PayPal currency conversion fee. Via the cheapest option: Use Revolut to make instant, low-cost payments in a foreign currency.
if your site has multiple currencies then use this to correctly round decimals according to the current user's currency and culture :
int currencyDecs = System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalDigits;
decimal roundedDecimalPrice = Math.Round(decimalPrice, currencyDecs, MidpointRounding.AwayFromZero);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With