Skip to main content

math_fround

Function math_fround 

Source
pub(crate) fn math_fround(
    _: &mut Interp,
    _t: Value,
    a: &[Value],
) -> Result<Value, Value>
Expand description

Math.fround(x)(ES2015)が丸ごと未対応だった。32bit 単精度浮動小数点として 表現可能な最も近い値へ丸める(WebGL/Canvas 等で GPU 側の float32 精度に 合わせる定番イディオム)。f64 -> f32 -> f64 の往復キャストで単精度の 丸め誤差を再現する。