mirror of
https://github.com/Dev1an/MsgPack.git
synced 2026-03-25 08:45:55 +00:00
Fix Float decoding bug
This commit is contained in:
parent
068bbe87dc
commit
101abe3e46
2 changed files with 8 additions and 3 deletions
|
|
@ -135,7 +135,8 @@ struct MsgPckSingleValueDecodingContainer: SingleValueDecodingContainer {
|
|||
guard decoder.storage[base] == FormatID.float32.rawValue else {
|
||||
throw Error.invalidFormat(decoder.storage[base])
|
||||
}
|
||||
return decoder.storage.read(at: base + 1)
|
||||
let bitPattern: UInt32 = decoder.storage.bigEndianInteger(at: base + 1)
|
||||
return .init(bitPattern: bitPattern)
|
||||
}
|
||||
|
||||
func decode(_ type: Double.Type) throws -> Double {
|
||||
|
|
|
|||
|
|
@ -40,5 +40,9 @@ for byte in encodedGraph {
|
|||
|
||||
let decoder = Decoder()
|
||||
|
||||
let int8 = try encoder.encode(Double(-10))
|
||||
try decoder.decode(Double.self, from: int8)
|
||||
func roundtrip<T: Codable>(value: T) throws -> T {
|
||||
return try decoder.decode(T.self, from: encoder.encode(value))
|
||||
}
|
||||
|
||||
var x: UInt64? = nil
|
||||
try roundtrip(value: false)
|
||||
|
|
|
|||
Loading…
Reference in a new issue