开发者

Convert Bitvector64.Section to Bitvector32

开发者 https://www.devze.com 2023-03-27 11:32 出处:网络
I have created the mysec variables for BitVector64. For the version less than 8 I would like to generate the value using the BitVector32

I have created the mysec variables for BitVector64. For the version less than 8 I would like to generate the value using the BitVector32

    static BitVector64.Section mySect1;
    static BitVector64.Section mySect2;
    static BitVector64.Section mySect3;

if (versions) > 7)
            mySect2 = BitVector64.CreateSection(14, mySect1);  // V1      - 3 bits
        else
            mySect3 = BitVector32.CreateSection(7, mySect2);

What I need now

  1. Mysect2 having value in BitVector64.Section. 开发者_如何学GoI need to convert explictity to BitVector32.Section and pass the aruguments.

Below converstion is not working for me

            mySect3 = BitVector32.CreateSection(7, (BitVector32.Section) mySect2);
  1. Will get the values in BItVector32.Section for mysect3 need to convert to the BitVector64.Section

Below converstion is not working for me

            mySect3 = BitVector32.CreateSection(7, (BitVector32.Section) mySect2) as BitVector34.Section;

or

   mySect3 = (BitVector64.Section) BitVector32.CreateSection(7, (BitVector32.Section) mySect2) ;


There is no type named "BitVector64" in the .NET framework. I would have to guess that you copied it from somewhere. Clearly this code you copied does not support an implicit conversion from BitVector32.Section to BitVector64.Section.

Which is unsurprising, the optimization it provides is extremely small. Rather the opposite, the conversion from uint to ulong is relatively expensive and not worth the very minor memory saving. Especially since this is a struct.

BitVector32 (and presumably BitVector64) is there explicitly to make bit manipulations fast and efficient. Faster than BitArray since it can take advantage of cpu register operations. Don't make it slow.

0

精彩评论

暂无评论...
验证码 换一张
取 消