This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Float Double numbers

 
cornel jew
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
Is there perhaps a way to get grip of the following :Float/Double MAX_MIN VALUES,POSITVE/NEGATIVE_INFINITY,NAN casting to int /float type etc, and using MATH methods on them.
It is very confusing remembering all the different results, i forgot sometimes what is what.
If anyone can perhaps explain the workings around it it will help, cos memorising this makes it difficult.
I have done a lot of mock questions, but hey i don't feel confident with it.
Thanks for any help.
Corn
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cornel,
What do you mean exactly by "get grip"?
[ May 18, 2003: Message edited by: Dirk Schreckmann ]
 
cornel jew
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Like doing arithmetic or casting operations for instance:
int i = (int)Float/Double.MIN/MAX_VALUE
float f = Float.NEGATIVE_INFINTY
int i = Math.round(f) etc.
Not to talk about using % / etc on them.
Maybe if i understand how double and float works i will understand.
I was doing a mock exam of Dan's operators and that was the type of questions which was asked.
Hope this will give you more info.
Thanks for the reply
Corn
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Honestly, I only have a vague idea of what you are talking about. I don't spend my time memorizing the Java API. If I need to use something, I look it up in the API docs. Eventually, I know some basics about several classes by using them over and over in actual programs. I honestly don't think an abstract description will be much help. You just have to use it in a program to see how it can be used
In this particular instance, I can't think of any meaningful examples where to use these constants from the Float and Double classes. I think all of them are often used for error checking, especially NAN and POSITIVE/NETAGIVE_INFINITY. Here is some pseudocode that can illustrate this:

I don't think I can be any more specific than that at the moment. Perhaps you should get a book, such as Core Java, that shows some examples of how to use such members of the API classes.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic