java – Divide BigDecimal by int

I am trying to divide the change owed by 1 to figure out how many dollars are owned. So if 3.60 is owed I want to divide that by 1 but I used BigDecimal to collect the change variable and can’t figure out how to divide it by 1.

This is the code I have tried but it’s not working. I needed to use BigDecimal for round off errors but I also need to use that value with int values.

BigDecimal Dollars = (Change.divide(1));

exploit – When parsing a string to a BigDecimal or BigInteger in Java, or BigInt in JavaScript, are there any known security issues around this?

When parsing a string to a BigDecimal or BigInteger in Java, or BigInt in JavaScript, are there any known security issues around this? Like if you take in the string without validating it’s just numbers, is there any risk?

Are there any known CVEs around this?

kotlin – Retornar true quando variável BigDecimal for diferente de nulo, caso contrário retornar false

  • Possuo um atributo do tipo BigDecimal x.

  • Preciso chamar um método exampleMethod.

  • Gostaria de passar por parâmetro true ou false dependendo se o x é nulo ou não, como no exemplo abaixo:

    val x: BigDecimal? = null 
    
    if (x != null)
        exampleMethod(true)
    else
        exampleMethod(false)
    

Porém, gostaria de saber se existe uma outra forma mais otimizada de verificar se é nulo e que retorne true ou false pra que eu não precise utilizar o if, como no exemplo em Java abaixo:

exampleMethod(Objects.nonNull(x))