Using BigInteger in Java to calculate unsigned long value

Posted on 2007-09-30
Last Modified: 2012-08-13
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;
Question by:azi98
    1 Comment
    LVL 7

    Accepted Solution

    new BigInteger("10").pow( number ).subtract( BigInteger.ONE ) will give you 10^number - 1

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now