Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 208653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:50:42+00:00 2026-05-11T17:50:42+00:00

So I am trying to do a few things with numbers in Objective C

  • 0

So I am trying to do a few things with numbers in Objective C and realize there is a plethora of options, and i am just bewildered as to which type to use for my app.

so here are the types.

  • NSNumber (which is a class)
  • NSDecmial (which is a struct)
  • NSDecimalNumber (which is a class)
  • float/double (which are primitive types)

so essentially what i need to do is take an NSString, which is representing decimal based hours. (10.4 would be 10 hours and (4/10)*60 minutes) and convert it into:

  1. a string representation D H:M (this needs division, multiplication and basic arithmatic)
  2. a Number type to store for easy calculations latter (will mostly be converting between NSTimeIntervals and doing subtractions)

Oh and i need to be able to do an Absolute value as well on these

It appears that the hard part is actually transitioning between the types.

To me this is a very trivial problem so I”m not sure if its getting late or because objective C numerical types suck, but i could use a hand.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:50:42+00:00Added an answer on May 11, 2026 at 5:50 pm

    Use primitive types (double, CGFLoat, NSInteger) for typical arithmetic and when you need to store a number as an instance variable that’s going to be used primarily for arithmetic in other places. You can use C math functions (abs(), pow(), etc) as needed. NSTimeInterval is a typedef for double, so you can interchange the two.

    Use NSNumber when you need to store a number as an object, for example if you’re creating an NSArray of numbers. Some parts of Cocoa like Core Data or key value coding deal more with NSNumber than primitive types, so you may find yourself using NSNumber more then usual in those situations. For example, if you write [timeKeepersArray valueForKeyPath:@"sum.seconds"] you’ll get back an NSNumber, so you may find it easier just to keep that variable instead of converting it to a primitive.

    Since it’s a small amount of extra code to convert between NSNumber and primitive types, usually your application will end up favoring one or the other depending on what you’re doing with numbers.

    Oh, and NSDecmial and NSDecimalNumber? Don’t worry too much about them, they only come up when you need really precise decimal operations, such as if you’re storing financial data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 120k
  • Answers 120k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You are correct that static initialization like that isn't thread… May 12, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer Yes, you can use Settings.Settings files for web application projects.… May 12, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer You need to override the Dispose method from Form Typically… May 12, 2026 at 12:15 am

Related Questions

I have a View with an exposed form . I am trying to a
I was hoping to implement a simple XMPP server in Java. What I need
I'm working on performance tuning my SQL Server 2008 database and am using the
RESOLVED After much confusion and frustration, I finally got my hard disk to interrupt.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.