Hi Arathi, The answer is because you are using -0 instead of -0.. There is no such value -0 as an integer it is just 0 therefore the compiler performs the following: -10. / -0 replaced with -10. / 0 converted to -10. / 0. therefore the answer is Positive! Only IEEE 754 recognizes a difference bewteen positive and negative zero!

If you had used the double negative zero you would get the result you expected without any replacement or conversion by the compiler. Regards, Manfred.

In order for the operation to take place, -0 must be cast to a double. To do that, the int value -0 must first be evaluated. Since there is no such int as -0, the value is evaluated as 0. This is cast to 0.0, and the operation is performed; leaving a result of POSITIVE_INFINITY.

Darryl Failla
Sun Certified Java 2 Programmer

Arathi Rajashekar
Ranch Hand

Joined: Nov 20, 2001
Posts: 112

posted

0

Originally posted by Manfred Leonhardt: Hi Arathi, The answer is because you are using -0 instead of -0.. There is no such value -0 as an integer it is just 0 therefore the compiler performs the following: -10. / -0 replaced with -10. / 0 converted to -10. / 0. therefore the answer is Positive! Only IEEE 754 recognizes a difference bewteen positive and negative zero!

If you had used the double negative zero you would get the result you expected without any replacement or conversion by the compiler. Regards, Manfred.

Thanks for your answer. I feel that when conversion by the compiler is made then 10.0/-0 is converted to 10.0/0. because -0 is converted as 0.0(with Casting). Am I correct. This what you meant to say. If its right, then i think you have to change the above code. [ January 11, 2002: Message edited by: Arathi Rajashekar ]

Don't get me started about those stupid light bulbs.