Swift: Basic Syntax [Bools, Floats, and Doubles]
Bool Bool is the Boolean data type . A Boolean can only ever hold one of two states : true or false . Swift var isDarkModeEnabled : Bool = false isDarkModeEnabled . toggle () // Flips the state: false -> true let isAuthenticated : Bool = true let hasAdminPrivileges : Bool = false print ( "Is the user logged in? : \( isAuthenticated )" ) // true print ( "Does user have admin access? : \( hasAdminPrivileges )" ) // false Float and Double Float and Double are used to store real numbers featuring fractional decimal points — known in computer science as floating - point numbers . Swift offers two main variations : Double : Represents a 64 - bit floating - point number . Float : Represents a 32 - bit floating - point number . In a standard 64 - bit environment , a Double has a precision of at least 15 decimal places , whereas a Float maxes out at 6 decimal places . While ...