Skip to content

Commit 82e63f8

Browse files
authored
Merge pull request #1918 from spevans/pr_nsdecimalnumber_intvalues_42
[4.2] NSDecimalValue: Dont use .doubleValue for integer properties.
2 parents 3a23d83 + f37fd49 commit 82e63f8

File tree

3 files changed

+283
-17
lines changed

3 files changed

+283
-17
lines changed

Foundation/Decimal.swift

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// This source file is part of the Swift.org open source project
22
//
3-
// Copyright (c) 2016 Apple Inc. and the Swift project authors
3+
// Copyright (c) 2016 - 2019 Apple Inc. and the Swift project authors
44
// Licensed under Apache License v2.0 with Runtime Library Exception
55
//
6-
// See http://swift.org/LICENSE.txt for license information
7-
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
6+
// See https://swift.org/LICENSE.txt for license information
7+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

1010
import CoreFoundation
@@ -226,6 +226,66 @@ extension Decimal : Hashable, Comparable {
226226
return _isNegative != 0 ? -d : d
227227
}
228228

229+
// Return the low 64bits of the integer part
230+
private var _unsignedInt64Value: UInt64 {
231+
if _exponent < -20 || _exponent > 20 {
232+
return 0
233+
}
234+
235+
if _length == 0 || isZero || magnitude < Decimal(0) {
236+
return 0
237+
}
238+
239+
var copy = self.significand
240+
241+
if _exponent < 0 {
242+
for _ in _exponent..<0 {
243+
_ = divideByShort(&copy, 10)
244+
}
245+
} else if _exponent > 0 {
246+
for _ in 0..<_exponent {
247+
_ = multiplyByShort(&copy, 10)
248+
}
249+
}
250+
let uint64 = UInt64(copy._mantissa.3) << 48 | UInt64(copy._mantissa.2) << 32 | UInt64(copy._mantissa.1) << 16 | UInt64(copy._mantissa.0)
251+
return uint64
252+
}
253+
254+
// Perform a best effort conversion of the integer value, trying to match Darwin for
255+
// values outside of UInt64.min .. UInt64.max. Used by NSDecimalNumber.
256+
internal var uint64Value: UInt64 {
257+
let value = _unsignedInt64Value
258+
if !self.isNegative {
259+
return value
260+
}
261+
262+
if value == Int64.max.magnitude + 1 {
263+
return UInt64(bitPattern: Int64.min)
264+
} else if value <= Int64.max.magnitude {
265+
var value = Int64(value)
266+
value.negate()
267+
return UInt64(bitPattern: value)
268+
} else {
269+
return value
270+
}
271+
}
272+
273+
// Perform a best effort conversion of the integer value, trying to match Darwin for
274+
// values outside of Int64.min .. Int64.max. Used by NSDecimalNumber.
275+
internal var int64Value: Int64 {
276+
let uint64Value = _unsignedInt64Value
277+
if self.isNegative {
278+
if uint64Value == Int64.max.magnitude + 1 {
279+
return Int64.min
280+
} else if uint64Value <= Int64.max.magnitude {
281+
var value = Int64(uint64Value)
282+
value.negate()
283+
return value
284+
}
285+
}
286+
return Int64(bitPattern: uint64Value)
287+
}
288+
229289
public var hashValue: Int {
230290
return Int(bitPattern: __CFHashDouble(doubleValue))
231291
}
@@ -250,6 +310,7 @@ extension Decimal : Hashable, Comparable {
250310
var rhsVal = rhs
251311
return NSDecimalCompare(&lhsVal, &rhsVal) == .orderedSame
252312
}
313+
253314
public static func <(lhs: Decimal, rhs: Decimal) -> Bool {
254315
var lhsVal = lhs
255316
var rhsVal = rhs

Foundation/NSDecimalNumber.swift

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// This source file is part of the Swift.org open source project
22
//
3-
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
3+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
44
// Licensed under Apache License v2.0 with Runtime Library Exception
55
//
6-
// See http://swift.org/LICENSE.txt for license information
7-
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
6+
// See https://swift.org/LICENSE.txt for license information
7+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

1010
/*************** Exceptions ***********/
@@ -289,43 +289,55 @@ open class NSDecimalNumber : NSNumber {
289289
// return 'd' for double
290290

291291
open override var int8Value: Int8 {
292-
return Int8(exactly: decimal.doubleValue) ?? 0 as Int8
292+
return Int8(truncatingIfNeeded: decimal.int64Value)
293293
}
294+
294295
open override var uint8Value: UInt8 {
295-
return UInt8(exactly: decimal.doubleValue) ?? 0 as UInt8
296+
return UInt8(truncatingIfNeeded: decimal.uint64Value)
296297
}
298+
297299
open override var int16Value: Int16 {
298-
return Int16(exactly: decimal.doubleValue) ?? 0 as Int16
300+
return Int16(truncatingIfNeeded: decimal.int64Value)
299301
}
302+
300303
open override var uint16Value: UInt16 {
301-
return UInt16(exactly: decimal.doubleValue) ?? 0 as UInt16
304+
return UInt16(truncatingIfNeeded: decimal.uint64Value)
302305
}
306+
303307
open override var int32Value: Int32 {
304-
return Int32(exactly: decimal.doubleValue) ?? 0 as Int32
308+
return Int32(truncatingIfNeeded: decimal.int64Value)
305309
}
310+
306311
open override var uint32Value: UInt32 {
307-
return UInt32(exactly: decimal.doubleValue) ?? 0 as UInt32
312+
return UInt32(truncatingIfNeeded: decimal.uint64Value)
308313
}
314+
309315
open override var int64Value: Int64 {
310-
return Int64(exactly: decimal.doubleValue) ?? 0 as Int64
316+
return decimal.int64Value
311317
}
318+
312319
open override var uint64Value: UInt64 {
313-
return UInt64(exactly: decimal.doubleValue) ?? 0 as UInt64
320+
return decimal.uint64Value
314321
}
322+
315323
open override var floatValue: Float {
316324
return Float(decimal.doubleValue)
317325
}
326+
318327
open override var doubleValue: Double {
319328
return decimal.doubleValue
320329
}
330+
321331
open override var boolValue: Bool {
322332
return !decimal.isZero
323333
}
334+
324335
open override var intValue: Int {
325-
return Int(exactly: decimal.doubleValue) ?? 0 as Int
336+
return Int(truncatingIfNeeded: decimal.int64Value)
326337
}
338+
327339
open override var uintValue: UInt {
328-
return UInt(exactly: decimal.doubleValue) ?? 0 as UInt
340+
return UInt(truncatingIfNeeded: decimal.uint64Value)
329341
}
330342

331343
open override func isEqual(_ value: Any?) -> Bool {

TestFoundation/TestDecimal.swift

Lines changed: 194 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class TestDecimal: XCTestCase {
3131
("test_SimpleMultiplication", test_SimpleMultiplication),
3232
("test_SmallerNumbers", test_SmallerNumbers),
3333
("test_ZeroPower", test_ZeroPower),
34-
("test_doubleValue", test_doubleValue)
34+
("test_doubleValue", test_doubleValue),
35+
("test_NSDecimalNumberValues", test_NSDecimalNumberValues),
3536
]
3637
}
3738

@@ -782,4 +783,196 @@ class TestDecimal: XCTestCase {
782783
XCTAssertEqual(nf.string(from: NSDecimalNumber(decimal: a)), "0.00")
783784
XCTAssertEqual(nf.string(from: NSDecimalNumber(decimal: b)), "0.00")
784785
}
786+
787+
func test_NSDecimalNumberValues() {
788+
let uint64MaxDecimal = Decimal(string: UInt64.max.description)!
789+
790+
// int8Value
791+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(0)).int8Value, 0)
792+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-1)).int8Value, -1)
793+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(1)).int8Value, 1)
794+
795+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-129)).int8Value, 127)
796+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(128)).int8Value, -128)
797+
798+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.min)).int8Value, Int8.min)
799+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.min)).int8Value, 0)
800+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.min)).int8Value, 0)
801+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.min)).int8Value, 0)
802+
803+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.max)).int8Value, Int8.max)
804+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.max)).int8Value, -1)
805+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.max)).int8Value, -1)
806+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.max)).int8Value, -1)
807+
808+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt8.max)).int8Value, -1)
809+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt16.max)).int8Value, -1)
810+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt32.max)).int8Value, -1)
811+
XCTAssertEqual(NSDecimalNumber(decimal: uint64MaxDecimal).int8Value, -1)
812+
813+
// uint8Value
814+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(0)).uint8Value, 0)
815+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-1)).uint8Value, UInt8.max)
816+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(1)).uint8Value, 1)
817+
818+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-129)).uint8Value, 127)
819+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(128)).uint8Value, 128)
820+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(256)).uint8Value, 0)
821+
822+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.min)).uint8Value, 128)
823+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.min)).uint8Value, 0)
824+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.min)).uint8Value, 0)
825+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.min)).uint8Value, 0)
826+
827+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.max)).uint8Value, 127)
828+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.max)).uint8Value, UInt8.max)
829+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.max)).uint8Value, UInt8.max)
830+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.max)).uint8Value, UInt8.max)
831+
832+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt8.max)).uint8Value, UInt8.max)
833+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt16.max)).uint8Value, UInt8.max)
834+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt32.max)).uint8Value, UInt8.max)
835+
XCTAssertEqual(NSDecimalNumber(decimal: uint64MaxDecimal).uint8Value, UInt8.max)
836+
837+
// int16Value
838+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(0)).int16Value, 0)
839+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-1)).int16Value, -1)
840+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(1)).int16Value, 1)
841+
842+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-32769)).int16Value, 32767)
843+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(32768)).int16Value, -32768)
844+
845+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.min)).int16Value, -128)
846+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.min)).int16Value, Int16.min)
847+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.min)).int16Value, 0)
848+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.min)).int16Value, 0)
849+
850+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.max)).int16Value, 127)
851+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.max)).int16Value, Int16.max)
852+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.max)).int16Value, -1)
853+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.max)).int16Value, -1)
854+
855+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt8.max)).int16Value, 255)
856+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt16.max)).int16Value, -1)
857+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt32.max)).int16Value, -1)
858+
XCTAssertEqual(NSDecimalNumber(decimal: uint64MaxDecimal).int16Value, -1)
859+
860+
// uint16Value
861+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(0)).uint16Value, 0)
862+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-1)).uint16Value, UInt16.max)
863+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(1)).uint16Value, 1)
864+
865+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-32769)).uint16Value, 32767)
866+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(32768)).uint16Value, 32768)
867+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(65536)).uint16Value, 0)
868+
869+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.min)).uint16Value, 65408)
870+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.min)).uint16Value, 32768)
871+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.min)).uint16Value, 0)
872+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.min)).uint16Value, 0)
873+
874+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.max)).uint16Value, 127)
875+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.max)).uint16Value, 32767)
876+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.max)).uint16Value, UInt16.max)
877+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.max)).uint16Value, UInt16.max)
878+
879+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt8.max)).uint16Value, 255)
880+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt16.max)).uint16Value, UInt16.max)
881+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt32.max)).uint16Value, UInt16.max)
882+
XCTAssertEqual(NSDecimalNumber(decimal: uint64MaxDecimal).uint16Value, UInt16.max)
883+
884+
// int32Value
885+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(0)).int32Value, 0)
886+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-1)).int32Value, -1)
887+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(1)).int32Value, 1)
888+
889+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-32769)).int32Value, -32769)
890+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(32768)).int32Value, 32768)
891+
892+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.min)).int32Value, -128)
893+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.min)).int32Value, -32768)
894+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.min)).int32Value, Int32.min)
895+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.min)).int32Value, 0)
896+
897+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.max)).int32Value, 127)
898+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.max)).int32Value, 32767)
899+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.max)).int32Value, Int32.max)
900+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.max)).int32Value, -1)
901+
902+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt8.max)).int32Value, 255)
903+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt16.max)).int32Value, 65535)
904+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt32.max)).int32Value, -1)
905+
XCTAssertEqual(NSDecimalNumber(decimal: uint64MaxDecimal).int32Value, -1)
906+
907+
// uint32Value
908+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(0)).uint32Value, 0)
909+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-1)).uint32Value, UInt32.max)
910+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(1)).uint32Value, 1)
911+
912+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-32769)).uint32Value, 4294934527)
913+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(32768)).uint32Value, 32768)
914+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(65536)).uint32Value, 65536)
915+
916+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.min)).uint32Value, 4294967168)
917+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.min)).uint32Value, 4294934528)
918+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.min)).uint32Value, 2147483648)
919+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.min)).uint32Value, 0)
920+
921+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.max)).uint32Value, 127)
922+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.max)).uint32Value, 32767)
923+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.max)).uint32Value, UInt32(Int32.max))
924+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.max)).uint32Value, UInt32.max)
925+
926+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt8.max)).uint32Value, 255)
927+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt16.max)).uint32Value, 65535)
928+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt32.max)).uint32Value, UInt32.max)
929+
XCTAssertEqual(NSDecimalNumber(decimal: uint64MaxDecimal).uint32Value, UInt32.max)
930+
931+
// int64Value
932+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(0)).int64Value, 0)
933+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-1)).int64Value, -1)
934+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(1)).int64Value, 1)
935+
936+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-32769)).int64Value, -32769)
937+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(32768)).int64Value, 32768)
938+
939+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.min)).int64Value, -128)
940+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.min)).int64Value, -32768)
941+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.min)).int64Value, -2147483648)
942+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.min)).int64Value, Int64.min)
943+
944+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.max)).int64Value, 127)
945+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.max)).int64Value, 32767)
946+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.max)).int64Value, 2147483647)
947+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.max)).int64Value, Int64.max)
948+
949+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt8.max)).int64Value, 255)
950+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt16.max)).int64Value, 65535)
951+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt32.max)).int64Value, 4294967295)
952+
XCTAssertEqual(NSDecimalNumber(decimal: uint64MaxDecimal).int64Value, -1)
953+
954+
// uint64Value
955+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(0)).uint64Value, 0)
956+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-1)).uint64Value, UInt64.max)
957+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(1)).uint64Value, 1)
958+
959+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(-32769)).uint64Value, 18446744073709518847)
960+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(32768)).uint64Value, 32768)
961+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(65536)).uint64Value, 65536)
962+
963+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.min)).uint64Value, 18446744073709551488)
964+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.min)).uint64Value, 18446744073709518848)
965+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.min)).uint64Value, 18446744071562067968)
966+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.min)).uint64Value, 9223372036854775808)
967+
968+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int8.max)).uint64Value, 127)
969+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int16.max)).uint64Value, 32767)
970+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int32.max)).uint64Value, UInt64(Int32.max))
971+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(Int64.max)).uint64Value, UInt64(Int64.max))
972+
973+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt8.max)).uint64Value, 255)
974+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt16.max)).uint64Value, 65535)
975+
XCTAssertEqual(NSDecimalNumber(decimal: Decimal(UInt32.max)).uint64Value, 4294967295)
976+
XCTAssertEqual(NSDecimalNumber(decimal: uint64MaxDecimal).uint64Value, UInt64.max)
977+
}
785978
}

0 commit comments

Comments
 (0)