`acos` returning `-nan`?

Timon Gehr timon.gehr at gmx.ch
Sat Nov 23 18:09:43 UTC 2019


On 23.11.19 18:31, Jonathan Levi wrote:
> ...
> Any idea why that is and how I could solve it?
> 
> BTW this is the how that number is created: `cos(a.angle)*cos(b.angle) - 
> dot(a.axis*sin(a.angle),(b.axis*sin(b.angle)))`
> 
> 

You can print the number at a higher precision:

writefln!"%.16f"(failing); // -1.0000000130385160

I.e., it is actually slightly smaller than -1.
You either have to debug your data source or manually clip the value 
into the range [-1.0,1.0] before you call acos.


More information about the Digitalmars-d mailing list