0
0
Swiftprogramming~5 mins

Int, Double, Float number types in Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an Int in Swift?
An Int is a whole number without any decimal part. It can be positive, negative, or zero, like 5, -3, or 0.
Click to reveal answer
beginner
What is the difference between Double and Float in Swift?
Double stores decimal numbers with more precision (more digits after the decimal) than Float. Double uses 64 bits, Float uses 32 bits.
Click to reveal answer
intermediate
Why choose Double over Float?
Choose Double when you need more accurate decimal numbers, like in money calculations or measurements.
Click to reveal answer
beginner
How do you declare a variable of type Int in Swift?
Use var number: Int = 10 to declare an integer variable named number with value 10.
Click to reveal answer
beginner
What happens if you try to store a decimal number in an Int variable?
You get an error because Int cannot hold decimal numbers. You must use Double or Float for decimals.
Click to reveal answer
Which Swift type would you use to store the number 42?
ADouble
BInt
CFloat
DString
Which type has more precision for decimal numbers?
ADouble
BInt
CFloat
DBool
What will happen if you assign 3.14 to an Int variable?
AIt causes a compile-time error
BIt stores 3 only
CIt stores 3.14 correctly
DIt converts to a string
Which type uses 32 bits to store numbers?
AInt
BDouble
CFloat
DBool
Why might you prefer Double over Float?
ADouble stores whole numbers only
BDouble is faster
CDouble uses less memory
DDouble has higher precision
Explain the differences between Int, Double, and Float in Swift.
Think about whole vs decimal numbers and precision.
You got /3 concepts.
    When should you use Double instead of Float in your Swift programs?
    Consider accuracy and size of numbers.
    You got /3 concepts.