math - How to implement sin() in a swift made calculator? -


i'm making calculator , have decided add more operations standard 4. in trying implement sin , cos have run following problem.

 @ibaction func evaluate(sender: anyobject) {     secondnumber = int(screen.text!)!     if operation == "+" {         result = firstnumber + secondnumber     } else if operation == "-" {         result = firstnumber - secondnumber     } else if operation == "x" {         result = firstnumber * secondnumber     } else if operation == "/" {         result = firstnumber / secondnumber     } else if operation == "%" {         result = firstnumber % secondnumber     } else if operation == "^" {         result = firstnumber^secondnumber     } else if operation == "sin" {         result = sin(degtorad(double(firstnumber)))     } 

where degtorad defined

func degtorad(degrees: double) -> double { // m_pi defined in darwin.c.math return m_pi * 2.0 * degrees / 360.0 

}

i following error on sin line.

"ambiguous reference member "sin""

why occuring , how go using sin? i've imported darwin not believe issue, i'm still new swift i'm sure i'm doing easy incorrect appreciated.

if, @zazu suggests, it's scoping problem, can clarify scoping with:

result = foundation.sin(...) 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -