Floating-Point Arithmetic

Float and double types cause floating-point arithmetic, as specified in the IEEE 754 standard. What’s so special about this? Well, recall the inherent imprecision that exists in floating-point arithmetic. For most applications, that’s fine, but scientific or monetary computation might be better off with different numeric types (such as decimal).

But there’s more: Floating-point numbers have a series of special values to deal with infinities and mathematical nonsense also known as NaN (not a number). The C# specification contains tables to indicate the behavior of all arithmetic operators for all possible combinations of input. If the result of a computation is too large to be represented as a floating-point number, the ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.