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?

  • 2
    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
  • 1
    Google for "IEEE 754". There is of course +0 and -0 which are equal but not the same. – gnasher729 Jan 19 '17 at 22:18

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.

  • @KSteff thanks for detailed answer. it was helpful. – js_ Jul 20 '12 at 15:04
  • 3
    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


  • 1
    These are constants which are floating point values, not different kinds of floating point value. You may as well add PI, e, and 42 to your list. – Pete Kirkham Jan 19 '17 at 13:34
  • @PeteKirkham And how PI would help you with floating-point arithmetic? Yep, not kinds, but may be pretty useful to prevent mistakes with floating values anyway. – Netsu Jan 19 '17 at 13:47
  • I would put this suggestion to comment, not answer, but ironically have no karma enough yet. – Netsu Jan 19 '17 at 13:50

protected by gnat Jan 19 '17 at 12:08

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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