BigInteger.ONE

Discussion in 'Java' started by au714@osfn.org, Feb 23, 2006.

  1. Guest

    Why does the BigInteger class have a few pre-defined static constants,
    as in ZERO, ONE, and TEN?

    Seems very arbitrary. What is the reasoning behind this in the first
    place?


    FGB
     
    , Feb 23, 2006
    #1
    1. Advertisements

  2. BigIntegers are immutable, therefore it makes sense to share some
    common instances.

    Traditionally, these three numbers crop up rather frequently, so
    offering "shorthand" instances for them makes sense. Even more if you
    consider the "static import" feature of java 1.5 - setBase(TEN) is much
    clearer then setBase(new BigInteger(10))
     
    Stefan Schulz, Feb 23, 2006
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pete kirkham
    Replies:
    5
    Views:
    629
    pete kirkham
    Aug 13, 2003
  2. xarax
    Replies:
    6
    Views:
    8,980
    xarax
    Sep 8, 2003
  3. David Goulet

    BigInteger

    David Goulet, Jan 25, 2004, in forum: Java
    Replies:
    1
    Views:
    745
  4. nick
    Replies:
    0
    Views:
    1,082
  5. nick
    Replies:
    1
    Views:
    33,157
    Eric Sosman
    Oct 26, 2004
  6. news.frontiernet.net
    Replies:
    6
    Views:
    1,422
    news.frontiernet.net
    Apr 16, 2004
  7. loveNUNO
    Replies:
    2
    Views:
    1,206
    loveNUNO
    Nov 20, 2003
  8. Merciadri Luca
    Replies:
    4
    Views:
    1,047
Loading...