18 lines
533 B
Swift
18 lines
533 B
Swift
import Foundation
|
|
|
|
private let numberFormatter: NumberFormatter = {
|
|
let formatter = NumberFormatter()
|
|
formatter.numberStyle = .decimal
|
|
formatter.maximumFractionDigits = 2
|
|
return formatter
|
|
}()
|
|
|
|
extension String.StringInterpolation {
|
|
mutating func appendInterpolation(double: Double, fractionDigits: Int = 2) {
|
|
let formatter = NumberFormatter()
|
|
formatter.numberStyle = .decimal
|
|
formatter.maximumFractionDigits = fractionDigits
|
|
appendInterpolation(numberFormatter.string(from: NSNumber(value: double))!)
|
|
}
|
|
}
|