Re: Strange java behaviour
- From: Lew <lew@xxxxxxxxxxx>
- Date: Fri, 29 Sep 2006 23:54:52 -0400
priyom wrote:class NanTest {
public static void main ( String args [ ] ) {
int intX = 10 ; // line 1
float floatX = 10 ; // line 2
double doubleX = floatX / 0 ; // line 3
double doubleY = intX / 0 ; // line 4
System . out . println ( doubleX == doubleY ) ; // line 5
}
}
It throws exception on line 4 but not on line 3.
Could anyone please explain this.
Patricia Shanahan wrote:
Line 4 is an int division by zero, and there is no way to represent the
result as an int, so it throws an exception.
Line 3 is a float division by zero, and there is a value,
Float.POSITIVE_INFINITY, that represents the result of dividing a
positive float by a zero float.
http://docs-pdf.sun.com/800-7895/800-7895.pdf
and
http://docs.sun.com/source/806-3568/ncg_goldberg.html
The latter is the HTML form of the former.
- Lew
.
- Prev by Date: WebStart API development - bypass security
- Next by Date: Re: Virtual coordinate systems
- Previous by thread: WebStart API development - bypass security
- Next by thread: how to run a jar, from another jar.
- Index(es):
Relevant Pages
|