.binaryBitPattern
๐พ ็จๅผ๏ผreplit
extension BinaryFloatingPoint {
/// `num.signBitPattern`
public var signBitPattern: String {
return sign == .plus ? "0" : "1"
}
/// `num.binaryBitPattern`
public var binaryBitPattern: String {
return signBitPattern
+ String(exponentBitPattern, radix: 2)
+ String(significandBitPattern, radix: 2)
}
}
๐็ฏไพ๏ผ
let x = Double.pi
x.binaryBitPattern
// โญโโ exp โโโฎโญโโโโโโโโโโโโโโโโโโ significand โโโโโโโโโโโโโโโโโโโโฎ
// 0100000000001001001000011111101101010100010001000010110100011000
// โณ sign
Swift โฉ
String โฉ String(_:radix:uppercase:) โญ๏ธ ๅฐๆดๆธ็จไบ้ฒไฝใๅ ซ้ฒไฝใๅๅ ญ้ฒไฝ่กจ็คบใ
BinaryFloatingPoint extension.
Last updated