3
In one of my methods I make the following comparison, as in the example below:
public static void main(String[] args) {
BigDecimal valor = new BigDecimal("100");
exemplo(valor);
}
public static void exemplo(BigDecimal valor) {
if (valor.compareTo(new BigDecimal("50.000")) == 1 || valor.compareTo(new BigDecimal("50.000")) == 0) {
System.out.println("número maior");
}
}
Passing as parameter the value "100", the problem is that the class Bigdecimal ends up considering the value "100" higher than the value "50.000", I tried to pass the value as: "50.000.00" to try to solve the problem, but the class does not allow me to do this, some solution?
But 100 is greater than 50. Could clarify better what you intend?
– Pablo Almeida
putting as an example our money, I am comparing 100 real with 50,000 thousand, there is no way to be bigger..
– Emanoel
No, you’re comparing $100 to $50,000.
– Maniero
@bigown like so, I’m confused now I’m doing something wrong?
– Emanoel
@Emanoel I tried to clarify the confusion in the answer. Take a look.
– Pablo Almeida