Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!

# Thinking in Java excercise

Sami Devine
Ranch Hand
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
Posts: 2700
Hint: look at the classes Double and Float.

Sami Devine
Ranch Hand
Posts: 44
Thanks Henry. I think I got it right now.

Rob Spoor
Sheriff
Posts: 20527
54
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.

Sami Devine
Ranch Hand
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
Posts: 20527
54
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
Posts: 12122
30
Wouldn't the smallest number also be negative? -100 is smaller than .0000000000000000000000000001