JavaScript DecimalFormat implementation