如何将小数点移至整数的100分之几? [英] How can I move the decimal point to the 100ths of an integer?

查看:44
本文介绍了如何将小数点移至整数的100分之几?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是一个愚蠢的问题,但我无法弄清楚如何将代表美分的整数转换为美元.

This seems like a silly question but I cant figure out how to convert an integer number that represent cents to dollars.

3000-> 30.00

3000 -> 30.00

在javascript中...

in javascript...

我使用的是ParseFloat,但这只是给我返回整数=/我需要始终显示美分,即使其为0.

I was using ParseFloat but it's only giving me back the integer =/ I need to always display the cents even if its 0.

推荐答案

使用 toFixed() .

var num = 3000;

alert( (num/100).toFixed( 2 ) ); // alerts 30.00

这篇关于如何将小数点移至整数的100分之几?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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