• 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: Math operations for NSNumber
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Math operations for NSNumber


  • Subject: Re: Math operations for NSNumber
  • From: Ken Tozier <email@hidden>
  • Date: Thu, 31 May 2007 21:41:23 -0400


On May 31, 2007, at 8:01 PM, Nick Zitzmann wrote:


On May 31, 2007, at 5:31 PM, Ken Tozier wrote:

I know there are ways to extract C types from NSNumbers and numerous functions in Math.h for performing calculations but why doesn't NSNumber support calculations directly?

Because NSNumber is supposed to contain primitives in an array/ dictionary/set, not replace the primitives.


For example, say you have an NSArray of NSNumbers and you want to convert them in-place to their nth root. If NSNumber supported math functions, you could use NSArray's makeObjectsPerformSelector method to do it without having to loop through each, extract the value, get the root, and replace the number in the array.

There's nothing stopping you from writing your own method that does this, is there?

I could do something that simulated it but without access to the actual storage for the number, it would just add the overhead of extracting the number converting it and replacing the instance. If Apple did it on the other hand, they could perform the operation in the actual storage without all that stuff. _______________________________________________


Cocoa-dev mailing list (email@hidden)

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: 
 >Math operations for NSNumber (From: Ken Tozier <email@hidden>)
 >Re: Math operations for NSNumber (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: "selected" table view column header
  • Next by Date: RE: Math operations for NSNumber
  • Previous by thread: Re: Math operations for NSNumber
  • Next by thread: Re: Math operations for NSNumber
  • Index(es):
    • Date
    • Thread