Search:

Type: Posts; User: helloworld922

Search: Search took 0.09 seconds.

  1. Re: Break down BigDecimal to individual values

    Nope, just re-assign it to the same variable. The operation will return a new BigInteger already.

    BigInteger a = new BigInteger("1");
    a = a.add(a);
  2. Re: Break down BigDecimal to individual values

    I would recommend against using BigDecimal for this kind of operation, us a BigInteger instead.

    Second, you're update loop never re-assigns i. BigDecimals and BigIntegers are immutable and need to...
  3. Re: Break down BigDecimal to individual values

    I don't see why you would be running out of memory, 100! should fit in ~66 bytes, and even in it's string representation is ~158 characters long.

    The JVM's default heap size is quite "small"...
  4. Re: Break down BigDecimal to individual values

    Using BigDecimals and BigIntegers in Java has always been a pain.

    You're last bit of code is actually computing sum = sum * sum * i, not sum = sum * i
  5. Re: Break down BigDecimal to individual values

    That's probably the easiest method for isolating decimal digits in a BigDecimal.

    What overall problem are you trying to solve? Perhaps there's a better way to solve that.
Results 1 to 5 of 5