Approx Sin
Returns sin
(module
(func $pow (export "pow") (param $x f32) (param $y f32) (result f32)
(local $out f32)
(local $index f32)
f32.const 1
set_local $out
f32.const 1
set_local $index
(block $b0
(loop $l0
(f32.mul
(get_local $out)
(get_local $x)
)
set_local $out
(f32.add
(get_local $index)
(f32.const 1)
)
tee_local $index
get_local $y
f32.gt
br_if 1
br 0
)
)
get_local $out
)
(func $sin (export "sin") (param $x f32) (result f32)
(f32.sub
(f32.add
(f32.sub
(get_local $x)
(f32.div
(call $pow (get_local $x) (f32.const 3))
(f32.const 6)
)
)
(f32.div
(call $pow (get_local $x) (f32.const 5))
(f32.const 120)
)
)
(f32.div
(call $pow (get_local $x) (f32.const 7))
(f32.const 5040)
)
)
)
)
Last updated