范围错误:精度超出范围
当超出允许范围的数字被传递到 toExponential
、toFixed
或 toPrecision
时,会发生 JavaScript 异常 "精度超出范围"。
¥The JavaScript exception "precision is out of range" occurs when a number that's
outside of the allowed range was passed into toExponential
, toFixed
, or toPrecision
.
信息
¥Message
RangeError: toExponential() argument must be between 0 and 100 (V8-based & Safari) RangeError: toFixed() digits argument must be between 0 and 100 (V8-based & Safari) RangeError: toPrecision() argument must be between 1 and 100 (V8-based & Safari) RangeError: precision -1 out of range (Firefox)
错误类型
什么地方出了错?
¥What went wrong?
其中一种方法存在超出范围的精度参数:
¥There was an out of range precision argument in one of these methods:
Number.prototype.toExponential()
,要求参数介于 0 和 100 之间(含)。Number.prototype.toFixed()
,要求参数介于 0 和 100 之间(含)。Number.prototype.toPrecision()
,要求参数介于 1 到 100 之间(包含 1 和 100)。