You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I have found a little bug, decoding a hexadecimal value can be rounded, for example 0x400ff040 returns 0x400ff000.
The bug is in the inbox functions for integer types, such as internal func unbox(_ value: Any, as type: UInt32.Type) throws -> UInt32? function.
If valueencodes an hex integer number, it is internally converted in a float number by the instruction let number = NSNumber(value: value): just print number for checking.
So I have modified the function as :
internal func unbox(_ value: Any, as type: UInt32.Type) throws -> UInt32? {
if let string = value as? String {
if string.starts (with: "0x"), let uint32 = UInt32 (string.dropFirst (2), radix: 16) {
return uint32
}else if let uint32 = UInt32 (string) { // Decimal
return uint32
}else{
throw DecodingError._typeMismatch (at: self.codingPath, expectation: type, reality: value)
}
}else{
return nil
}
}
Best regards,
Pierre Molinaro
The text was updated successfully, but these errors were encountered:
Thank you very much for your work.
I think I have found a little bug, decoding a hexadecimal value can be rounded, for example 0x400ff040 returns 0x400ff000.
The bug is in the
inbox
functions for integer types, such asinternal func unbox(_ value: Any, as type: UInt32.Type) throws -> UInt32?
function.If
value
encodes an hex integer number, it is internally converted in a float number by the instructionlet number = NSNumber(value: value)
: just printnumber
for checking.So I have modified the function as :
Best regards,
Pierre Molinaro
The text was updated successfully, but these errors were encountered: