JavaScript/Number:修订间差异
来自康健生活
创建页面,内容为“== 引言 == == 四舍五入 == {{leftrightflex|<syntaxhighlight lang="javascript"> Math.round(55.4355 * 100) / 100;</syntaxhighlight>|{{consoleout|<pre> 55.44 </pre…” |
|||
| 第1行: | 第1行: | ||
== 引言 == | == 引言 == | ||
== 四舍五入 == | == 四舍五入 == | ||
=== Math.round === | |||
{{leftrightflex|<syntaxhighlight lang="javascript"> | {{leftrightflex|<syntaxhighlight lang="javascript"> | ||
Math.round(55.4355 * 100) / 100;</syntaxhighlight>|{{consoleout|<pre> | Math.round(55.4355 * 100) / 100;</syntaxhighlight>|{{consoleout|<pre> | ||
55.44 | 55.44 | ||
</pre>}}}} | |||
=== toFixed === | |||
{{leftrightflex|<syntaxhighlight lang="javascript"> | |||
(new Number(100.345)); | |||
(new Number(100.345)).toFixed(2);</syntaxhighlight>|{{consoleout|<pre> | |||
Number {100.345} | |||
'100.34' | |||
</pre>}}}} | </pre>}}}} | ||
2022年1月19日 (三) 14:14的版本
No categories