Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AhmedMenaim/4bd00d9131ae21a240c1361fa101f3f1 to your computer and use it in GitHub Desktop.
Save AhmedMenaim/4bd00d9131ae21a240c1361fa101f3f1 to your computer and use it in GitHub Desktop.
Menaim Academy - Swift Course - Data types -> Float, Double, Bool & Charcater
import Foundation
//MARK: - Constants & Variables
let name = "Ahmed"
//name = "Mohamed" // Will give an error
var age = 25
age = 26
print(age)
// MARK: - Data Types
// 1- Int 2- Float 3- Double 4- String 5- Character 6- Bool
var newNumber: Int = 5
var newName: String = "Mohammed"
let spaceCheck: Bool = false
// Int -> Unsigned, Signed
// Int -> Unsigned -> 5, 6 ,19 without + or -
//UInt32 , UInt64, UInt8, UInt16
// Int -> signed -> -5, 6 ,-19
//Int32 , Int64, Int8, Int16
// Numeric Literals
let descimalNumber = 17
let octalNumber = 0o21 // 17 in octal
let binaryNumber = 0b10001 // 17 in binary
let hexaNumber = 0x11 // 17 in hexaDecimal
// Float -> 32-bit
let floatNumber:Float = 15.92823799 // Max -> 5 numbers after the sign = .92823
// Double -> 64-bit
let doubleNumber = 15.9282392826638391827 // Max -> 14 numbers after the sign = .9282392823
// Bool -> True, False
var myBool = true
myBool = false
// Character
var myChar: Character = "A"
//var myChar: Character = "BA" // Character can contain only one character
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment