Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #7552

Re: BitSet vs BigInteger (false Android doc)

Date 2011-09-03 12:37 -0700
From Patricia Shanahan <pats@acm.org>
Newsgroups comp.lang.java.programmer
Subject Re: BitSet vs BigInteger (false Android doc)
References (1 earlier) <4e613b65$0$311$14726298@news.sunsite.dk> <yJCdnamwfpVooPzTnZ2dnUVZ_umdnZ2d@earthlink.com> <j3rflb$lh6$2@news.albasani.net> <KOmdnWyhfYV_FPzTnZ2dnUVZ_s-dnZ2d@earthlink.com> <j3tqr7$vp8$1@news.albasani.net>
Message-ID <_ZGdna1ucfWYH__TnZ2dnUVZ_oudnZ2d@earthlink.com> (permalink)

Show all headers | View raw


On 9/3/2011 11:15 AM, Jan Burse wrote:
> Patricia Shanahan schrieb:
>> On 9/2/2011 1:51 PM, Jan Burse wrote:
>>> Patricia Shanahan schrieb:
>>>> Also, they have more freedom of action in implementing BitSet
>>>
>>> True, actually I was expecting to see a more clever BitSet,
>>> but in JDK 1.6.0_26 its just this long array.
>>
>> Are you looking at the actual Android implementations for the classes?
>>
>> Patricia
>
> I don't think that Android uses some special BitSet resp. BigInteger,
> since then classes are java.*.

That just means that they must support exactly the interface specified
in the API documentation.

>
> But it looks that nevertheless the implementation in JDK and Android are
> not verbatim the same:
>
> Here is the Android BitSet XOR:
...

> http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/util/BitSet.java.htm

Thanks for the link. I found their BigInteger implementation at
http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/math/BigInteger.java.htm

It uses a NativeBN implementation, which appears from various comments
and fields to be sign-and-magnitude based, not 2's complement. The bit
manipulation methods use a method prepareJavaRepresentation that I think
converts to 2's complement.

It is definitely not the implementation in the normal JDK, so any
arguments based on how it is coded, or on the internal representation it
uses, are inapplicable to the Andriod implementation.

It does appear to be consistent with the comment you quoted in the first
message of this thread:

>      Slow Two's Complement Bitwise Operations
>     This API includes operations for bitwise operations
>     in two's complement representation. Two's complement
>     is not the internal representation used by this
>     implementation, so such methods may be inefficient.
>     Use BitSet for high-performance bitwise operations
>     on arbitrarily-large sequences of bits.

On something like this, I would be inclined to believe the developers,
and follow their advice. I certainly don't see any reason to assume the
documentation is false.

Patricia

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-02 21:48 +0200
  Re: BitSet vs BigInteger (false Android doc) Arne Vajhøj <arne@vajhoej.dk> - 2011-09-02 16:23 -0400
    Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-02 13:34 -0700
      Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-02 22:51 +0200
        Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-02 18:58 -0700
          Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-03 20:15 +0200
            Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-03 12:37 -0700
              Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-03 22:46 +0200
                Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-03 16:32 -0700
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-04 02:58 +0200
                Re: BitSet vs BigInteger (false Android doc) Arne Vajhøj <arne@vajhoej.dk> - 2011-09-05 19:32 -0400
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 08:58 +0200
                Re: BitSet vs BigInteger (false Android doc) Lew <lewbloch@gmail.com> - 2011-09-06 00:41 -0700
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 11:57 +0200
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 12:12 +0200
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 12:44 +0200
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 12:02 +0200
                Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-06 13:38 -0700
                Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-06 10:33 -0700
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 22:28 +0200
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 22:41 +0200
                Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-06 14:34 -0700
                Re: BitSet vs BigInteger (false Android doc) Lew <lewbloch@gmail.com> - 2011-09-06 14:51 -0700
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-07 00:33 +0200
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-07 00:40 +0200
            Re: BitSet vs BigInteger (false Android doc) Arne Vajhøj <arne@vajhoej.dk> - 2011-09-05 19:26 -0400
      Re: BitSet vs BigInteger (false Android doc) Robert Klemme <shortcutter@googlemail.com> - 2011-09-03 17:01 +0200
    Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-02 22:49 +0200
      Re: BitSet vs BigInteger (false Android doc) Gene Wirchenko <genew@ocis.net> - 2011-09-02 14:48 -0700
  Re: BitSet vs BigInteger (false Android doc) Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-03 13:54 -0400

csiph-web