Simple question. In my code I set a double to an integer, like so:
int square_root = sqrt(sum);
Do I need to explicitly cast this?
Without casting, I seem to get the result I desired, i.e. floor(sqrt(x))
sqrt(4200) = 64
sqrt(42) = 6
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.
is equivalent in C to:
Now be aware that if the integral part of a
doubleis not representable in anintthe behavior is undefined (in both cases).