# [about zero]...

chao-long liao

Ranch Hand

Posts: 78

posted 14 years ago

- 0

public void check()

{

System.out.println(Math.min(-0.0,+0.0));

System.out.println(Math.max(-0.0,+0.0));

System.out.println(Math.min(-0.0,+0.0) == Math.max(0.0,+0.0));

}

answer: -0.0 +0.0 true

if there are positive and negative zero,

why the answer of (Math.min(-0.0,+0.0) == Math.max(0.0,+0.0))

will be true??

thanks for help.

{

System.out.println(Math.min(-0.0,+0.0));

System.out.println(Math.max(-0.0,+0.0));

System.out.println(Math.min(-0.0,+0.0) == Math.max(0.0,+0.0));

}

answer: -0.0 +0.0 true

if there are positive and negative zero,

why the answer of (Math.min(-0.0,+0.0) == Math.max(0.0,+0.0))

will be true??

thanks for help.

Desai Sandeep

Ranch Hand

Posts: 1157

posted 14 years ago

- 0

Hi,

This has to do with the implementation of Math.min() and Math.max() methods.These methods treat -0.0 as less than +0.0.However, these are NOT numeric comparisions.

When you test -0.0 == +0.0 you are doing a numeric comparision which results in true.

Hope this helps,

Sandeep

This has to do with the implementation of Math.min() and Math.max() methods.These methods treat -0.0 as less than +0.0.However, these are NOT numeric comparisions.

When you test -0.0 == +0.0 you are doing a numeric comparision which results in true.

Hope this helps,

Sandeep

**SCJP2, OCSD(Oracle JDeveloper), OCED(Oracle Internet Platform)**