Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No * candidates produce the expected result type FloatingPointRoundingRule

In Swift 3 I am getting the following error (which wasn't happening in Swift 2):

No * candidates produce the expected result type FloatingPointRoundingRule

I don't know what I need to do to fix it.

I am trying to convert latitude decimal to degrees/minutes/seconds

extension CLLocationDegrees {        
    mutating func toLatitudeSeconds() -> String {
        var seconds = Int(round(self * 3600)) //error here
        // etc ...
    }
}
like image 290
tyczj Avatar asked Oct 11 '25 18:10

tyczj


1 Answers

The rounding functions were changed to be called on an instance rather than being global functions. You're basically trying to do self.round(self*3600) which doesn't work because the round function takes either no argument or an argument of type FloatingPointRoundingRule.

You probably want:

var seconds = Int((self*3600).rounded())
like image 54
dan Avatar answered Oct 14 '25 07:10

dan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!