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

Thinking in Java excercise

Sami Devine
Ranch Hand

Joined: Jan 30, 2011
Posts: 44
Exercise 9: (1) Display the largest and smallest numbers for both float and double exponential notation.

This is my solution to this excercise. Is this the expected answer? I manipulated the bases and exponent till I did not get Floating point too large error.

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Hint: look at the classes Double and Float.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Sami Devine
Ranch Hand

Joined: Jan 30, 2011
Posts: 44
Thanks Henry. I think I got it right now.



Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

Are you sure those are the right constants? Double.MAX_EXPONENT is 1023, I don't think that's the maximum value (hint hint) for a double.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Sami Devine
Ranch Hand

Joined: Jan 30, 2011
Posts: 44
Hi Rob thanks for the hint
This question was under the Exponents section. So I think the expected answer is exponents and not MAX_VALUE and MIN_VALUE.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

I think the question is too vague about this. Do they mean the largest double value which can be written in exponential notation, or do they mean the largest exponential part when writing a double in exponential notation?
I would post both answers and tell them to pick which one they want
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

Wouldn't the smallest number also be negative? -100 is smaller than .0000000000000000000000000001


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thinking in Java excercise
 
Similar Threads
K&B ch-3 Ques-2
Math.abs()
range of float and double
Math.random().....any formula to adjust required range?
Double and Float size