BitString with a given length

10 views
Skip to first unread message

Koon Sang Khong

unread,
Jun 23, 2017, 1:36:54 AM6/23/17
to ASN.1 Development Tools
Hello,

According to the Java API for BitString constructor below:

public BitString(int length)
Create a new bit string of a given length

It seems that the length will be fixed.  However, I realized that it is not the case.  The length will actually change when we call setBit(), as illustrated below:

        BitString bs = new BitString(1);
        bs.setBit(1, false);
        bs.setBit(5, false);
        System.out.println("size:"+bs.getBitSize());   //prints 6

Is this the intended behaviour?

Thank you.

Ryan Hu

unread,
Jun 23, 2017, 2:56:45 AM6/23/17
to asn1-develo...@googlegroups.com
Yes, this is intended.  If you don't set bit beyond the preset bit length, that's fine. But if you set bit beyond that, the bit string will grow.

--
You received this message because you are subscribed to the Google Groups "ASN.1 Development Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to asn1-development-tools+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Regards,

Zhiren Hu

huzh...@gmail.com

Reply all
Reply to author
Forward
0 new messages