Skip to content

Commit db6ef73

Browse files
committed
fix linux builds by keeping the decimal string init in a compiler directive
1 parent 849819f commit db6ef73

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Sources/Floating Point Conversion.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ extension BigUInt {
4949
guard integer.sign == .plus else { return nil }
5050
assert(integer.floatingPointClass == .positiveNormal)
5151

52-
// keeping around in case the `Decimal._mantissa` property gets deprecated in the future.
53-
// let significand = BigUInt("\(integer.significand)")!
52+
#if os(Linux)
53+
// `Decimal._mantissa` has an internal access level on linux, and it might get
54+
// deprecated in the future, so keeping the string implementation around for now.
55+
let significand = BigUInt("\(integer.significand)")!
56+
#else
5457
let significand = {
5558
var start = BigUInt(0)
5659
for (place, value) in integer.significand.mantissaParts.enumerated() {
@@ -59,6 +62,7 @@ extension BigUInt {
5962
}
6063
return start
6164
}()
65+
#endif
6266
let exponent = BigUInt(10).power(integer.exponent)
6367

6468
self = significand * exponent
@@ -134,7 +138,7 @@ extension BigInt.Sign {
134138
}
135139
}
136140

137-
#if canImport(Foundation)
141+
#if canImport(Foundation) && !os(Linux)
138142
private extension Decimal {
139143
var mantissaParts: [UInt16] {
140144
[

0 commit comments

Comments
 (0)