In our next app, we depart temporarily from our
GradeBook case study to declare a class called
Account that maintains a bank account’s balance. Most account balances are not whole numbers (such as 0, –22 and 1024), rather they’re numbers that include a decimal point, such as 99.99 or –20.15. For this reason, class
Account represents the account balance as a real number. C# provides three simple types for storing real numbers—
float, double, and
double are called floating-point types. The primary difference between them and
decimal is that
decimal variables store a limited range of real numbers precisely, whereas floating-point variables store only approximations of real numbers, ...