I wonder if you could explain the Overflow in floating-point types.
float.MaxValue == float.MaxValue + 1 // returns true
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.
Because the
1is way too small to make a dent in thefloat.MaxValuevalue.Anything less than 1e32 will fall below the precision of the float, so it’s in effect the same as adding a zero.
Edit:
ulrichb showed that a value of 1e23 does actually affect float.MaxValue, which has to mean that you are not comparing floats at all, but doubles. The compiler converts all values to doubles before adding and comparing.