I'm trying to make a code to answers a Math Function that includes Acos "Cos-1(A)", where A is a double -10.0000 <= A <= 10.0000, I had try several numbers in that range, and most of those give me a NaN as return that make all the operation Fails.
Edited: As the documentation said, with Math.Acos is I put a number out of the range -1<=d<=1 will return a NaN, I were attempting to make a function that make the same, step by step to allow those values.
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.
C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.
In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.
As MSDN says, the argument to the Math.Acos
function must be in range [-1,1]
. Otherwise, the result will be NaN
.
Your expectation that it should return something for those values is incorrect.
The arccosine function answers the question "what angle has this cosine?". But there is no value that you can give to the cosine function to yield a result less than -1 or greater than 1. We say that its "range is [-1, 1]".
Since there's no angle with a cosine value outside this range, it is not possible to give you an angle back when you ask Acos
for one. So instead it gives you the answer of NaN
.
The documentation for Math.Acos
says this too:
Parameters:
d: (System.Double) a number representing a cosine, where d must be greater than or equal to -1, but less than or equal to 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With