How to get mathemical PI constant in Swift

前端 未结 3 1823
梦如初夏
梦如初夏 2020-11-30 00:03

I am trying to find a way to include the PI constant in my Swift code. I already found help in another answer, to import Darwin which I know gives me a

3条回答
  •  渐次进展
    2020-11-30 00:35

    warning: 'M_PI' is deprecated: Please use 'Double.pi' or '.pi' to get the value of correct type and avoid casting.

    surprisingly, .pi also works fine. M_PI is deprecated as of Swift 4.2.1, Xcode 10.1, which is the current version I am using. SO, Use .pi, or Double.pi

提交回复
热议问题