Fix Double decoding bug

This commit is contained in:
Damiaan Dufaux 2017-08-02 22:05:36 +02:00
parent 1255f3c3a7
commit 068bbe87dc
2 changed files with 4 additions and 4 deletions

View file

@ -142,8 +142,8 @@ struct MsgPckSingleValueDecodingContainer: SingleValueDecodingContainer {
guard decoder.storage[base] == FormatID.float64.rawValue else {
throw Error.invalidFormat(decoder.storage[base])
}
let bitPattern: UInt64 = decoder.storage.read(at: base + 1)
return .init(bitPattern)
let bitPattern: UInt64 = decoder.storage.bigEndianInteger(at: base + 1)
return .init(bitPattern: bitPattern)
}
func decode(_ type: String.Type) throws -> String {

View file

@ -40,5 +40,5 @@ for byte in encodedGraph {
let decoder = Decoder()
let int8 = try encoder.encode(Int8(-57))
try decoder.decode(Int8.self, from: int8)
let int8 = try encoder.encode(Double(-10))
try decoder.decode(Double.self, from: int8)