I’m trying to do some c++ programming and the following line gives me a “Floating point exception” at runtime:
realAnswer=(0-720+5*1440)/((775-720)/(750-720))+720;
What could be causing the problem? (realAnswer is a double)
Edit: added the slash
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.
Apart from the missing * that Petar has pointed out, your calculation uses only integers while you wish to get a double. The answer you are getting now is rounded down (723).
The following will get you the double precision I assume you are looking for. I have tested this by compiling and running it:
This gives 723.927 as a result.