The following table lists the double forms of standard mathematical functions, along with checks that should be performed to ensure a proper input domain, and indicates whether they can also result in range or pole errors, as reported by the C Standard. Instead of preventing range errors, programmers should attempt to detect them and take alternative action if a range error occurs. Range errors usually cannot be prevented because they are dependent on the implementation of floating-point numbers as well as on the function being applied. Programmers can prevent domain and pole errors by carefully bounds-checking the arguments before calling mathematical functions and taking alternative action if the bounds are violated. An example of a pole error is log(0.0), which results in negative infinity. In both cases, the function will return some value, but the value returned is not the correct result of the computation. Contrastingly, 10 raised to the 1-millionth power, pow(10., 1e6), cannot be represented in many floating-point implementations because of the limited range of the type double and consequently constitutes a range error. Paragraph 2 statesĪ domain error occurs if an input argument is outside the domain over which the mathematical function is defined.Ī pole error (also known as a singularity or infinitary) occurs if the mathematical function has an exact infinite result as the finite input argument(s) are approached in the limit.Ī range error occurs if the mathematical result of the function cannot be represented in an object of the specified type, due to extreme magnitude.Īn example of a domain error is the square root of a negative number, such as sqrt(-1.0), which has no meaning in real arithmetic. The C Standard, 7.12.1, defines three types of errors that relate specifically to math functions in.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |