Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

10. The Class Library, Part 1 > Floating Point Numbers

Floating Point Numbers

The floating point types Single and Double are used to represent numeric values with a fractional component (rational numbers for you math geeks out there). As with using Int32 values to represent values, the Double is the go-to floating point type. It’s faster and more accurate. Wait a second. “More accurate”? There’s a “less accurate”? Well, here’s the tricky thing about floating points: they’re only approximations of a value.

Do you know the value of pi? 3.141592653589...yada yada. The value has been calculated to over a trillion digits. In the world of computers, we just don’t have that many to work with. So, like pi, which is usually truncated to 3.14159, we pick a certain number of digits (called the precision), and arbitrarily decide that the rest don’t matter. (In the .NET Framework, a double value maintains 15 decimal digits of precision, while a single maintains 7.)


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial