Swift: extract float from byte data
I'm looking for a robust and elegant way to extract four big-endian bytes from an array as a Float. I can get a UInt32 with the bits via something like this: let data: [Byte] = [0x00, 0x00, 0x00, 0x40, 0x86, 0x66, 0x66, 0x00] let dataPtr = UnsafePointer<Byte>(data) let byteOffset = 3 let bits = UnsafePointer<UInt32>(dataPtr + byteOffset)[0].bigEndian But I can't figure out a good way to convert this into a Float in Swift. For example, in Java: float f = Float.intBitsToFloat(bits) or in C: float f = *(float *)&bits; I tried casting the dataPtr to a float UnsafePointer, but then the endianness