0
0
Swiftprogramming~10 mins

Numeric literal formats in Swift - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a hexadecimal integer literal.

Swift
let hexNumber = 0[1]1A
Drag options to blanks, or click blank then click option'
Ab
Bo
Cx
Dd
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0b or 0o instead of 0x for hexadecimal.
Forgetting the letter after 0.
2fill in blank
medium

Complete the code to declare a binary integer literal.

Swift
let binaryNumber = 0[1]1011
Drag options to blanks, or click blank then click option'
Ax
Bo
Cd
Db
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0x or 0o instead of 0b for binary.
Omitting the prefix.
3fill in blank
hard

Fix the error in the code to declare an octal integer literal.

Swift
let octalNumber = 0[1]17
Drag options to blanks, or click blank then click option'
Ao
Bx
Cb
Dd
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0b or 0x instead of 0o for octal.
Writing octal numbers without prefix.
4fill in blank
hard

Fill both blanks to declare a floating-point literal with an exponent.

Swift
let floatNumber = 1.25[1]3[2]2
Drag options to blanks, or click blank then click option'
Ae
Bp
C+
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'p' instead of 'e' for decimal exponents.
Omitting the sign after the exponent.
5fill in blank
hard

Fill all three blanks to declare a hexadecimal floating-point literal with a negative exponent.

Swift
let hexFloat = 0x1.[1]p[2][3]
Drag options to blanks, or click blank then click option'
A8
B4
C-
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'e' instead of 'p' for hexadecimal floating-point literals.
Omitting the sign before the exponent.