Hi,

Oliver Wong wrote:

>>>>> BigDecimal bigDecimal = new BigDecimal("1.00");

>>>>> BigDecimal bigDecima2 = new BigDecimal("1");

>>>>>

>>>>> System.out.println(bigDecimal.equals(bigDecima2));

> ...

> As I've mentioned elsewhere in this newsgroup (but not within this

> thread), the concept of equality is context dependent. Are "1.00" and

> "1.0" equal? Perhaps yes, if you're talking about pure mathematical

> numbers. Perhaps no, if you're talking about engineering measurements

> with specific tolerance levels
Ah, OK, that is a point I did not consider! I was only thinking of the

"mathematical" equality.

Still, I am not convinced that the two values should not be mathematical

equal (which you did not say), but I see (and agree to) your point, and

it might be enough to say "they are not *generally* equal".

I know that compareTo() does exactly what I want, but I just think,

"b.compareTo(BigDecimal.ZERO)==0" is not as beautiful and readable as

"b.equals(BigDecimal.ZERO)" or even (if operator overloading would be

allowed) "b==BigDecimal.ZERO" (or perhaps "b===BigDecimal.ZERO", if you

think that is is not a good idea to allow to overload the

"referential-equality-comparison-operator" ==).

Ciao,

Ingo, daydreaming