• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1975
  • Last Modified:

Using BigInteger in Java to calculate unsigned long value

I need to convert this C# code to Java where __count is a ULong type and STR_LENGTH=8. How do I use BigInteger here.

        static test()
            int index;
            // compute ( 10 ^ STR_LENGTH ) - 1

            __count= 1UL;
            for (index = 0; index < STR_LENGTH; ++index)
                __count*= 10UL;
1 Solution
new BigInteger("10").pow( number ).subtract( BigInteger.ONE ) will give you 10^number - 1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now