in Objective-C, value of type double/float can only be NAN, INFINITY, & normal number?

  softwareengineering

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?

3

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.

3

There’s also DBL_EPSILON, LDBL_EPSILON and FLT_EPSILON; FLT_MIN, FLT_MAX, etc.

3

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website Kho Theme wordpress Kho Theme WP Theme WP

LEAVE A COMMENT