/* * @descript: 保留两位小数,如果小数点大于两位小数,就向上取值保留两位小数<br/> * @time 2016-07-13 */function mathCeil(number){ var result = Number(number); text = result.toString(); var pointIndex = text.indexOf("."); if(pointIndex != -1){ var poi…
换行的字符串 "This string\nhas two lines" 字符串中使用单引号时应该怎么写 'You\'re right, it can\'t be a quote' 把数字变成字符串并保留两位小数 var n = 123456.789 n.toFixed(0); //"123457" n.toFixed(2); //"123456.79" parseFloat(str)str以非数字开头,则返回NaN parseFloat(str)…
1,下面是一个浮点类型的数字转成String字符串的例子 1 2 var f = 123.32342342 var s:String = "\(f)" //123.32342342 2,如果要保留两位小数 1 2 var f = 123.32342342 var s = String(format: "%.2f", f) //123.32…