habib
09-24-2002, 01:22 PM
Hi
Is there a way of displaying numbers in 2 decimal places? I am using the function below to convert amounts to different currencies, and want to show the amount upto 2 decimal places. For example:
This amount 19.200000000000003 should be displayed as 19.20.
function convert_amount (amount) {
var input_amount = amount;
var sa_rate = 16;
var us_rate = 1.4;
var eu_rate = 1.6;
if (getCookie('home_location') == 'UK') {
return '£'+(input_amount); }
else
if (getCookie('home_location') == 'SA') {
return 'R'+(input_amount * sa_rate); }
else
if (getCookie('home_location') == 'US') {
return '$'+(input_amount * us_rate); }
else
if (getCookie('home_location') == 'EU') {
return '€'+(input_amount * eu_rate); }
}
Is there a way of displaying numbers in 2 decimal places? I am using the function below to convert amounts to different currencies, and want to show the amount upto 2 decimal places. For example:
This amount 19.200000000000003 should be displayed as 19.20.
function convert_amount (amount) {
var input_amount = amount;
var sa_rate = 16;
var us_rate = 1.4;
var eu_rate = 1.6;
if (getCookie('home_location') == 'UK') {
return '£'+(input_amount); }
else
if (getCookie('home_location') == 'SA') {
return 'R'+(input_amount * sa_rate); }
else
if (getCookie('home_location') == 'US') {
return '$'+(input_amount * us_rate); }
else
if (getCookie('home_location') == 'EU') {
return '€'+(input_amount * eu_rate); }
}