{infiniteZest} // Articles. Tutorials. Utilities.
Categories Test: Swift - Floating Point Types

4. Which of the following represents 255 in Swift?

 [CORRECT ANSWER] let num = 25_5 [CORRECT ANSWER] let binNum = 0b11111111 [CORRECT ANSWER] let binNum = 0b1111_1111 [CORRECT ANSWER] let hexNum = 0xFF

Results
Correct Answer: let num = 25_5; let binNum = 0b11111111; let binNum = 0b1111_1111; let hexNum = 0xFF;
Explanation
Even though you might not choose to write 255 as 25_5, it is a valid representation. The underscore can be used to separate the digits. So, they all represent 255.
Take the Test
Take the complete test on this topic. You will be able to review answers to questions and get a test score.

Take the Test

Question 4 of 5 Tags: This article talks about decimal numbers in Swift, including Float, Double, and CGFloat. Also talks about Binary, Octal, and Hexadecimal representations. Tags: Test on Float and Double types in Swift, as well as binary, octal, and hex representations. Tags: Test on Float and Double types in Swift, as well as binary, octal, and hex representations. Tags: This series of articles goes through the basics of Swift. It introduces Playgrounds and REPL; Variables and Constants; Int, Float, Bool; Tuples, Type Aliases, Type Inference, Type Safety, and more. Tags: This article discusses the boolean types in Swift and contrasts with how these types are used in C and Objective-C. Tags: Test on Boolean Types in Swift. Tags: This article goes through the usage of various integer types in Swift (including Int and UInt).