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
// main.swift | |
// UnitConverter | |
// | |
import Foundation | |
/// 소숫점 n자리에서 반올림 extension | |
extension Double { | |
func rounded(toPlace places: Int)-> Double { | |
let divisor = pow(10.0, Double(places)) | |
return (self * divisor).rounded()/divisor |
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
// main.swift | |
// UnitConverter | |
// | |
// Created by Doran & Dominic on 02/04/2019. | |
// Copyright © 2019 hw. All rights reserved. | |
import Foundation | |
// 소숫점 n자리에서 반올림 extension |