lesson

Updated 6 days ago Β· 2 views
Every app on your phone treats player scores, shop prices, and toggle switches differently, even though your computer stores all of them as binary bits.
A data type is a classification that tells the computer what kind of value a piece of data is, how much memory to allocate for it, and what operations can be performed with it.
πInteractive diagram
How do you decide between counting whole items and measuring exact quantities?
Integers: Whole Numbers
An integer is any positive or negative whole number, including zero, that has no fractional or decimal part.
You use integers whenever you are counting discrete items that cannot be split, such as
playerScore = 150, livesRemaining = 3, or studentID = 1042.What happens when a value falls in between two whole numbers?
Real: Decimal Numbers
A real number (frequently referred to as a float or floating-point number) is any number that contains a fractional part indicated by a decimal point.
You select the real data type for continuous measurements or financial quantities, such as
itemPrice = 19.99, runnerSpeed = 8.45, or discountRate = 0.15.Not every piece of data is numericβhow does a computer store a simple yes-or-no state?