Reputation: 3725
I am beginner in Java and I am just reading one of the pdfs for beginners like me. So in my book I found this:
So for example the floating point numbers may be within the range of
1.4E-45 to 3.4028235E+38
So according to my math, that number can be very small (near the zero) or quite large, but it CAN NOT be a negative number.
Am I correct?
Upvotes: 3
Views: 5241
Reputation: 28133
The book states the MIN_VALUE
and MAX_VALUE
for the floating point types. This range describes available precision but it is certainly not the case that all values must fall between MIN_VALUE
and MAX_VALUE
as you can easily confirm by assigning zero or a negative number to a float
variable.
Floating point values (float
and double
) can be one of the following:
NaN
(not a number)-MAX_VALUE
and -MIN_VALUE
MIN_VALUE
and MAX_VALUE
Upvotes: 2
Reputation: 9536
Float range is approximately ±3.40282347E+38F (6-7 significant decimal digits) Java implements IEEE 754 standard.
Refer below links
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
http://cs-fundamentals.com/java-programming/java-primitive-data-types.php
Upvotes: 2
Reputation: 2969
here you are considering the minimimum value of float .
minimum value of float (MIN_VALUE)
prints the most accurate float
it can get, but not the mathematical minimum it can represent.
integers
can hold negative values and integers
can be cast
to float
later.
think about that.
range of float : 32 bits -3.4E+38 to +3.4E+38
Upvotes: 1