以小数位显示值 [英] Display values in decimal places

查看:99
本文介绍了以小数位显示值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图以小数点后两位显示现金回报。我尝试使用.toFixed但是,它不起作用。我试图将100万作为1.00或1000万作为10.00等等,但总是在小数点后2位。



我尝试了什么:



I am trying to display Cash Return in two decimal places. I tried using .toFixed however, it's not working. I am trying to display 1 million as 1.00 or 10 million as 10.00 and so forth but always in 2 decimal place.

What I have tried:

var Return = document.getElementById("Cash").value;
var CashRate = document.getElementById("CashRate").value;

aCashReturnCompensation = (Return/1000000);

CashRate =   Math.pow(1+CashRate/100,1/365)-1;
document.getElementById("CashReturn").value=Math.floor(Return/Math.pow(1+CashRate,periods);

推荐答案

这对我有用。

This worked for me.
/1000000).toFixed(2);


这篇关于以小数位显示值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆