• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Dead Reckoning
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dead Reckoning


  • Subject: Re: Dead Reckoning
  • From: Marco S Hyman <email@hidden>
  • Date: Fri, 09 Oct 2015 22:10:25 -0700

The code is in Swift. #define is not an option.

> There’s very little reason to use macros for things like this, when an inline function is as efficient and safer.

IMHO function calls also help readability. My version looks like this:

private let π = M_PI
private let d2r = π / 180   // degrees to radians adjustment
private let r2d = 180 / π   // radians to degrees adjustments

private func degreesToRadians(degrees: Double) -> Double {
    return degrees * d2r
}

private func radiansToDegrees(radians: Double) -> Double {
    return radians * r2d
}


Yeah, "π = M_PI" wasn’t really needed.

Marc

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >Dead Reckoning (From: Michael de Haan  <email@hidden>)
 >Re: Dead Reckoning (From: Michael de Haan  <email@hidden>)
 >Re: Dead Reckoning (From: Graham Cox <email@hidden>)
 >Re: Dead Reckoning (From: Rick Mann <email@hidden>)
 >Re: Dead Reckoning (From: Graham Cox <email@hidden>)
 >Re: Dead Reckoning (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Dead Reckoning
  • Next by Date: Re: Dead Reckoning
  • Previous by thread: Re: Dead Reckoning
  • Next by thread: Re: Dead Reckoning
  • Index(es):
    • Date
    • Thread