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
@@ -380,54 +380,39 @@ internal class __CBORDecoder: Decoder, SingleValueDecodingContainer {
380
380
}
381
381
382
382
fileprivatefunc decodeFloatingPoint<T>(_ value:Any, as type:T.Type)throws->Twhere T:BinaryFloatingPoint{
383
-
letfloatingPoint:T
384
-
iflet half = value as?Half{
385
-
if half.isNaN {
386
-
if half.isSignalingNaN {
387
-
floatingPoint =.signalingNaN
388
-
}else{
389
-
floatingPoint =.nan
390
-
}
391
-
}else{
392
-
guardlet value =T(exactly: half)else{
393
-
throwDecodingError.dataCorrupted(DecodingError.Context(codingPath: codingPath, debugDescription:"Decoded CBOR number <\(half)> does not fit in \(type)."))
394
-
}
395
-
396
-
floatingPoint = value
383
+
iflet half = value as?Float16{
384
+
guard !half.isNaN else{
385
+
return half.isSignalingNaN ?.signalingNaN :.nan
397
386
}
398
-
}elseiflet float = value as?Float{
399
-
if float.isNaN {
400
-
if float.isSignalingNaN {
401
-
floatingPoint =.signalingNaN
402
-
}else{
403
-
floatingPoint =.nan
404
-
}
405
-
}else{
406
-
guardlet value =T(exactly: float)else{
407
-
throwDecodingError.dataCorrupted(DecodingError.Context(codingPath: codingPath, debugDescription:"Decoded CBOR number <\(float)> does not fit in \(type)."))
408
-
}
409
-
410
-
floatingPoint = value
387
+
guardlet value =T(exactly: half)else{
388
+
throwDecodingError.dataCorrupted(DecodingError.Context(codingPath: codingPath, debugDescription:"Decoded CBOR number <\(half)> does not fit in \(type)."))
411
389
}
412
-
}elseiflet double = value as?Double{
413
-
if double.isNaN {
414
-
if double.isSignalingNaN {
415
-
floatingPoint =.signalingNaN
416
-
}else{
417
-
floatingPoint =.nan
418
-
}
419
-
}else{
420
-
guardlet value =T(exactly: double)else{
421
-
throwDecodingError.dataCorrupted(DecodingError.Context(codingPath: codingPath, debugDescription:"Decoded CBOR number <\(double)> does not fit in \(type)."))
throwDecodingError.dataCorrupted(DecodingError.Context(codingPath: codingPath, debugDescription:"Decoded CBOR number <\(float)> does not fit in \(type)."))
400
+
}
401
+
402
+
return value
428
403
}
404
+
iflet double = value as?Double{
405
+
guard !double.isNaN else{
406
+
return double.isSignalingNaN ?.signalingNaN :.nan
407
+
}
408
+
guardlet value =T(exactly: double)else{
409
+
throwDecodingError.dataCorrupted(DecodingError.Context(codingPath: codingPath, debugDescription:"Decoded CBOR number <\(double)> does not fit in \(type)."))
0 commit comments