Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Wrapper Classes

 
Ramakrishnan Ponmudi
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(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.
 
Gianfranco Alongi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic