how to manipulate integers very very large?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sachin770
    New Member
    • Sep 2008
    • 3

    how to manipulate integers very very large?

    i am a beginner .can you give me idea how we can manipulate "LARGE" integers (positive or negative) of arbitrary size. These integers could be greater than MAX_INT or smaller than MIN_INT.

    using arrays or string?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Just use the BigInteger class.

    kind regards,

    Jos

    Comment

    • sachin770
      New Member
      • Sep 2008
      • 3

      #3
      i mean without using bigintegers and number can be greater than big integer also........... ....i.e 999999999999999 999999999999999 999999999

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by sachin770
        i mean without using bigintegers and number can be greater than big integer also........... ....i.e 999999999999999 999999999999999 999999999
        Do you mean you want to use big integers but you don't want to use the BigInteger
        class? How strange ... can you explain why you want to restrict yourself?

        kind regards,

        Jos

        Comment

        • sachin770
          New Member
          • Sep 2008
          • 3

          #5
          i want to know how it works because i am making progamme in ocaml to calculate big integers without using any directories.... ....pls help .....give me idea....how i can add two big integer in two different list or array?????????? ??

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by sachin770
            i want to know how it works because i am making progamme in ocaml to calculate big integers without using any directories.... ....pls help .....give me idea....how i can add two big integer in two different list or array?????????? ??
            A BigInteger doesn't use any directories; I don't know who told you that. The
            following example calculates 1000! (factorial). See how simple it is:

            Code:
            BigInteger fac= BigInteger.ONE;
            for (int i= 2; i <= 1000; i++)
               fac= fac.multiply(new BigInteger(""+i));
            System.out.println("1000! = "+fac);
            Read the API documentation for this class and see how one of its constructors
            can create a BigInteger given some other representation of such a number.

            kind regards,

            Jos

            Comment

            Working...