I have a constant for pi in my code:
const float PI = acos(-1);
Would it be better to declare it as a double? An answer to another question on this site said floating point operations aren’t exactly precise, and I’d like the constant to be accurate.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From standard:
Of the three (notice that this goes hand in hand with the 3 versions of
acos) you should chooselong doubleif what you are aiming for is precision (but you should also know that after some degree, further precision may be redundant in some cases).So you should use this to get the most precise result from
acos(Note: There might be some platform specific types or some user defined types which provide more precision)