Skip to main content

num_to_fixed

Function num_to_fixed 

Source
pub(crate) fn num_to_fixed(
    it: &mut Interp,
    t: Value,
    a: &[Value],
) -> Result<Value, Value>
Expand description

Number.prototype.toFixed(fractionDigits)。仕様上 fractionDigits0100 の範囲外(負値や 101 以上)なら RangeError を投げる必要があるが、以前は範囲外/ 非有限値を黙って 0 にクランプするだけで上限チェックが無く、(1).toFixed(500) の ような呼び出しが 10^500Infinity)を経由して壊れた出力になり得た (toPrecision には同種のチェックが既にあったが toFixed だけ欠けていた)。