File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,16 @@ extension BigUInt {
49
49
guard integer. sign == . plus else { return nil }
50
50
assert ( integer. floatingPointClass == . positiveNormal)
51
51
52
- let significand = BigUInt ( " \( integer. significand) " ) !
52
+ // keeping around in case the `Decimal._mantissa` property gets deprecated in the future.
53
+ // let significand = BigUInt("\(integer.significand)")!
54
+ let significand = {
55
+ var start = BigUInt ( 0 )
56
+ for (place, value) in integer. significand. mantissaParts. enumerated ( ) {
57
+ guard value > 0 else { continue }
58
+ start += ( 1 << ( place * 16 ) ) * BigUInt( value)
59
+ }
60
+ return start
61
+ } ( )
53
62
let exponent = BigUInt ( 10 ) . power ( integer. exponent)
54
63
55
64
self = significand * exponent
@@ -124,3 +133,20 @@ extension BigInt.Sign {
124
133
}
125
134
}
126
135
}
136
+
137
+ #if canImport(Foundation)
138
+ private extension Decimal {
139
+ var mantissaParts : [ UInt16 ] {
140
+ [
141
+ _mantissa. 0 ,
142
+ _mantissa. 1 ,
143
+ _mantissa. 2 ,
144
+ _mantissa. 3 ,
145
+ _mantissa. 4 ,
146
+ _mantissa. 5 ,
147
+ _mantissa. 6 ,
148
+ _mantissa. 7 ,
149
+ ]
150
+ }
151
+ }
152
+ #endif
You can’t perform that action at this time.
0 commit comments