- fixed-point 固定小数点
- Floating Point 浮動小数点
- exponential notation 指数表記
| method |
return |
| toFixed |
f |
| toPrecision |
f, e |
| toExponential |
e |
var int = 12345.67
;["toFixed", "toPrecision", "toExponential"].map(function(e){
return e + "|" + [1,2,3,4,5,6,7,8].map(function(e2){
return int[e](e2)
}).join("|")
}).join("\n")
| method/arg |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
| toFixed |
12345.7 |
12345.67 |
12345.670 |
12345.6700 |
12345.67000 |
12345.670000 |
12345.6700000 |
12345.67000000 |
| toPrecision |
1e+4 |
1.2e+4 |
1.23e+4 |
1.235e+4 |
12346 |
12345.7 |
12345.67 |
12345.670 |
| toExponential |
1.2e+4 |
1.23e+4 |
1.235e+4 |
1.2346e+4 |
1.23457e+4 |
1.234567e+4 |
1.2345670e+4 |
1.23456700e+4 |
| method/arg |
no-arg |
| toFixed |
12346 |
| toPrecision |
12345.6789 |
| toExponential |
1.23456789e+4 |
toPrecision
引数が少 <------------> 多
toExponential toFixed