Question: I am trying to convert this `Obj-C` code to `Swift` code but I don't know what the equivalent of this code should be ?

```
#define DEGREES_TO_RADIANS(degrees)((M_PI * degrees)/180)

```

I googled and found [this](https://stackoverflow.com/questions/24325477/how-to-use-a-objective-c-define-from-swift)

But I don't understand how to convert that in Swift in my case?

Answer: 
Also, to convert fron radians to degrees (if anyone stumbles upon this on google):

```
var degrees = radians * (180.0 / M_PI)

```
**Swift 4.2**

You can write global generic functions:

```
public func radians<T: FloatingPoint>(degrees: T) -> T {
    return .pi * degrees / 180
}

public func degrees<T: FloatingPoint>(radians: T) -> T {
    return radians * 180 / .pi
}

```

Example:

```
let cgFloat: CGFloat = 23.0
let double: Double = 23.0
let float: Float = 23.0
let int: Int = 23

let cgf = radians(degrees: cgFloat) // 0.4014 CGFloat
let d = radians(degrees: double)    // 0.4014 Double
let f = radians(degrees: float)     // 0.4014 Float
let i = radians(degrees: int)       // compile error

```

In case when you don't want to extension all your floating types like this 

```
extension FloatingPoint { ... }

```