Created
December 5, 2022 08:50
-
-
Save iamchiwon/50937bc8043f9a027b38f22dce4bc067 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Int { | |
public func decimal() -> String { | |
let numberFormatter = NumberFormatter() | |
numberFormatter.numberStyle = NumberFormatter.Style.decimal | |
return numberFormatter.string(from: NSNumber(value: self))! | |
} | |
public func currencyKRW() -> String { | |
let numberFormatter = NumberFormatter() | |
numberFormatter.numberStyle = .currency | |
numberFormatter.locale = Locale(identifier: "ko_KR") | |
return numberFormatter.string(from: NSNumber(value: self))! | |
} | |
} | |
extension Float { | |
public func decimal() -> String { | |
let numberFormatter = NumberFormatter() | |
numberFormatter.numberStyle = NumberFormatter.Style.decimal | |
return numberFormatter.string(from: NSNumber(value: self))! | |
} | |
public func currencyKRW() -> String { | |
let numberFormatter = NumberFormatter() | |
numberFormatter.numberStyle = .currency | |
numberFormatter.locale = Locale(identifier: "ko_KR") | |
return numberFormatter.string(from: NSNumber(value: self))! | |
} | |
} | |
extension FloatingPoint { | |
public var degreesToRadians: Self { return self * .pi / 180 } | |
public var radiansToDegrees: Self { return self * 180 / .pi } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment