Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Pelle Gelderblom
4,517 PointsMath in swift
How can I get math functions in swift, like Square root, cosine, sine and Pi or round a decimal down to a whole number? And how can I doing this in swift: 2 ^ 3 = 8
1 Answer

agreatdaytocode
24,757 PointsSwift Operators by NSHipster here
prefix operator √ {}
prefix func √ (number: Double) -> Double {
return sqrt(number)
}
Rob Parmenter
5,641 PointsRob Parmenter
5,641 PointsI'm not familiar with math functions beyond basic operators. A quick search in the documentation in Swift should help. I searched arithmetic and it brought up various search terms. It did bring up the NSDecimalNumber class and various other terms. Everything else is beyond my capability! I hope this helped in any way.