<div dir="auto"><div><div class="gmail_quote"><div dir="ltr">On Tue, Jun 12, 2018, 00:03 Stephan Houben <<a href="mailto:stephanh42@gmail.com">stephanh42@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi all,</div><div><br></div><div>I wrote a possible implementation of sindg:<br></div><div><br></div><div><a href="https://gist.github.com/stephanh42/336d54a53b31104b97e46156c7deacdd" target="_blank" rel="noreferrer">https://gist.github.com/stephanh42/336d54a53b31104b97e46156c7deacdd</a></div><div><br></div><div>This code first reduces the angle to the [0,90] interval.</div><div>After doing so, it can be observed that the simple implementation</div><div>  math.sin(math.radians(angle))</div><div>produces exact results for 0 and 90, and a result already rounded to nearest for</div><div>60.</div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">You observed this on your system, but math.sin uses the platform libm, which might do different things on other people's systems.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>For 30 and 45, this simple implementation is one ulp too low.</div><div>So I special-case those to return the correct/correctly-rounded value instead.</div><div>Note that this does not affect monotonicity around those values.</div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Again, monotonicity is preserved on your system, but it might not be on others. It's not clear that this matters, but then it's not clear that any of this matters...</div><div dir="auto"><br></div><div dir="auto">-n</div></div>