Numbers are present in the decimal format, like 10, 4, 235, and so on. However, there are other representations of number values. This includes binary representation, octal representation, hexadecimal representation, and so on. To create a variable and initialize it with an octal value, we use the
0o: This is the keyword to create an octal value in Swift.
octalDigit: This is the octal digit we want to use.
The value returned is an octal value.
// create variables with octal values let octal1 = 0o4; let octal2 = 0o7; let octal3 = 0o0; let octal4 = 0o75; // print the decimal equivalents print(octal1) print(octal2) print(octal3) print(octal4)
View all Courses