aspose file tools*
The moose likes Beginning Java and the fly likes Wrapper Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Wrapper Classes" Watch "Wrapper Classes" New topic
Author

Wrapper Classes

Ramakrishnan Ponmudi
Ranch Hand

Joined: Apr 20, 2004
Posts: 72
what is the purpose of fields in Float & Double
such as NaN, POSITIVE_INFINITY, NEGATIVE_INFINITY & TYPE
and how this values are obtained
Gianfranco Alongi
Greenhorn

Joined: Apr 20, 2004
Posts: 5
(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...
Gianfranco Alongi
Greenhorn

Joined: Apr 20, 2004
Posts: 5
Ohh.. by the way.. a perfect place to find this kind of information...
http://java.sun.com/j2se/1.4.2/docs/api/
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
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.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
 
subject: Wrapper Classes