what is the purpose of fields in Float & Double such as NaN, POSITIVE_INFINITY, NEGATIVE_INFINITY & TYPE and how this values are obtained
Joined: Apr 20, 2004
(1)Field: A Field provides information about, and dynamic access to, a single field of a class or an interface. The reflected field may be a class (static) field or an instance field. A Field permits widening conversions to occur during a get or set access operation, but throws an IllegalArgumentException if a narrowing conversion would occur. (2)Purpose of the named fields? Well, to be used. Like all methods and values.. They exist for reason.. If YOU don't understand why they exist, then you might have answered your own question (in some form). You are not intendend to use them.
Faster machines are a bad excuse<br />for writing unoptimized code<br />Like java...
Thanjai: what is the purpose of fields in Float & Double such as NaN, POSITIVE_INFINITY, NEGATIVE_INFINITY & TYPE and how this values are obtained For an explanation of the TYPE field, take a look at your other thread on the subject. Gianfranco: If YOU don't understand why they exist, then you might have answered your own question (in some form). You are not intendend to use them. We programmers are intended to use them. That's why we have access to them. One of the key subjects to understand here is how floating point numbers are represented by a finite 32-bit or 64-bit binary number. For a good introduction to that topic, I recommend reading the "Sum lack of precision!" thread over in the Cattle Drive forum. Follow the links in that conversation to further good explanations of the topic. In a nutshell, Double.NaN represents a special bit pattern used to create a floating-point type value that is not a number. Such a value might be the result of trying to calculate the square root of -1. POSITIVE_INFINITY and NEGATIVE_INFINITY are often used to represent floating-point values that are either too large or too small to be represented properly in a finite binary format. These values are also used to represent the result of dividing 1.0 by 0.0 and -1.0 by 0.0 respectively.