Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I knew double or float value can be not only normal value(-1.3, 0, 1.0, 2.3) but also NAN and INFINITY in Objective-C.

Is there other special values except for NAN and INFINITY for double/float value in Objective-C?

share|improve this question
There are no other "special" values that exists. Besides this easily could be answered by looking at the specification for double/float within the current Objective-C documentation. – Ramhound Jul 13 '12 at 14:32
@Ramhound of course, I sometimes tried searching in XCode Organizer's Documentation and google. But I couldn't find. Could you tell me the link to the document if you know it? – js_ Jul 13 '12 at 14:38
up vote 7 down vote accepted

Primitive types in Objective-C are covered by the C standard, since ObjC is an OOP system grafted to C.

Which transforms your question to "What special values are there for float/doubles in C?"

Most (if not all) compilers will generate float and double arithmetic that conforms to IEEE 754. In this standard, there are 2 types of NaNs (signalling and quiet), 2 infinities (+Infinity, -Infinity) and finite numbers (which include signed zeros, +0 and -0). The topic is too wide to even start, and you'd do yourself a favor by reading a book about floating point arithmetic.

However the C language standard (before C99) does not make any guarantees for conformance to IEEE 754 and this is only a de-facto standard.

Also, in C you check for NaN values with the isnan function.

share|improve this answer
@KSteff thanks for detailed answer. it was helpful. – js_ Jul 20 '12 at 15:04
Actually NANs can have a payload. Therefore there are two kinds of NANs (signaling and quiet) but each kind has multiple values. Not all implementations, however, have reasonable support for defining/accessing the payload or any guaranteed support for it. – Analog File Sep 18 '12 at 13:48
@AnalogFile Indeed, it seems I missed to point that out. The main point I wanted to make was the topic is too wide to be answered here in a reasonable way. – K.Steff Sep 18 '12 at 16:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.