Data Types and Constants
You have already encountered the Objective-C basic data type int
. As you will recall, a variable declared to be of type int
can be used to contain integral values only—that is, values that do not contain decimal digits.
The Objective-C programming language provides three other basic data types: float
, double
, and char
. A variable declared to be of type float
can be used for storing floating-point numbers (values containing decimal digits). The double
type is the same as type float
, typically with roughly twice the range. The char
data type can be used to store a single character, such as the letter a
, the digit character 6
, or a semicolon (more on this later).
In Objective-C, any literal number, single character, or ...
Get Programming in Objective-C, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.