## Floating Point Arithmetic

Eric Lippert has a serious of recent blog posts on Floating Point Arithmetic, if you were interested in or following any of my prior math quiz posts.

Also, Eric Gunnerson talks about floating point arithmetic in a December 2003 post, and posts to a canonical discussion of floating point arithmetic in “What Every Computer Scientist Should Know About Floating-Point Arithmetic.”

Some more math trivia: True or false?

- Math.Round(2.5) = 3.
- Math.Round returns an int.
- Both x and y are expressions of type Double and have the
**same exact**bit representation of a Double in memory. Neither are special cases—ie, NaN, negative zero, denormalized numbers, or infinities. Therefore, x = y. - If x is a Double and x = x, then double.Parse(x.ToString()) = x.
- Is MSDN documentation correct in stating the following about
`Double.Epsilon`

?

“Two apparently equivalent floating point numbers might not compare equal because of differences in their least significant digits. For example, the C# expression,`(double)1/3 == (double)0.33333`

, does not compare equal because the division operation on the left-hand side has maximum precision while the constant on the right-hand side is only precise to the visible digit.

Instead, determine if the two sides of a comparison are close enough to equal for your purposes by comparing whether the absolute value of the difference between the left and right-hand sides is less than**Epsilon**.”