I am trying to use the fmod function but I am not getting the results I am expecting.
Share
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.
It actually returns 9.299999999999994 due to floating point imprecision. Neither 55.8 or 9.3 can be exactly represented as a base 2 floating point number.
It’s a very common problem. One good reference is What Every Computer Scientist Should Know About Floating-Point Arithmetic.