SignedInteger
protocol SignedInteger : BinaryInteger, SignedNumeric where Self.Magnitude : BinaryInteger
-
Mechanica
Creates a string representing the given value in the binary base.
Example:
255.toBinaryString //"11111111" Int16(-1).toBinaryString //"1111111111111111" 1.toBinaryString //"0000000000000000000000000000000000000000000000000000000000000001" (Int 64 bit) 1.toBinaryString //"00000000000000000000000000000001" (Int 32 bit)
Note
Negative integers are converted with the two’s complement operation. For signed binary useString(:,radix:)
Example:
String(Int8(-127), radix: 2) // -1111111 Int8(-127).toBinaryString // 10000001
Declaration
Swift
public var toBinaryString: String