Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SWIFT trig functions

I don't see any reference to standard trig functions (Sine, Cosine, Tangent) in the SWIFT language reference. What is the recommended way to add them? Are there libraries that should be loaded?

like image 316
mcgregor94086 Avatar asked Dec 25 '22 08:12

mcgregor94086


1 Answers

You can still use them as global functions as defined in the Darwin module (imported automatically with Foundation)

import Darwin
var num = CDouble(10)
sin(num)
like image 165
drewag Avatar answered Jan 08 '23 04:01

drewag