0

I am novice in Objective-c ,i want to know ,in Objective-C, how can I check whether input value is integer or float like 2, 3.00,

here 2 is integer and 3.00 is float data-type 

how can i find-out it.Thanks in advance

7
  • Why do you need to know, is the difference important? Commented Mar 14, 2015 at 18:54
  • yes @Wain i want to develop a polynomial program . Buy using that user can find out and kind of polynomial value. Assume , 3x3 - 5x2 + 6 and ..(3.31 x 108 + 2.01 x 107) their are two polynomial .First one is normal integer polynomial and second one is float-polynomial . i want to check ... user input belong in which polynomial ... Commented Mar 14, 2015 at 19:01
  • And how are you taking the user input in? Commented Mar 14, 2015 at 19:15
  • 1
    This was already answered here, I suggest you check it out: stackoverflow.com/questions/15020989/… Commented Mar 14, 2015 at 19:30
  • 1
    Just assume all numbers are floating point. You're going to have to convert them anyway to solve. Commented Mar 14, 2015 at 20:06

1 Answer 1

1

So, the simplest solution is probably to check each string input for a period (.) character (possibly also checking for another number after it) because checking that the number 3.00 and 3 are different is quite hard (because they are only different if you tell them to be).

The easiest way to do that would be with rangeOfString:.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.