bit manipulation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shawn B.

    #1

    bit manipulation

    Greetings,

    Thanks for helping me with some of the C# bit manipulation issues I've asked
    about over the last couple days. I've got a first public preview of the
    Binary8, Binary16, Binary32, and Binary64 classes I've worked on.



    Use it like you would any other int, short, byte, whatever... I've
    overloaded all but one of the operators (^ -- don't know how to do so).


    Examples,

    Binary8 bin = "10110100";
    Binary16 bin = "1101";

    Binary8 bin2 = bin << 3;
    Binary64 bin3 = "10101";
    Binary8 bin4 = bin3; // accepable because it doesn't exceed 8 bits

    Binary8 bin = 0xFF;
    Binary16 bin2 = ~bin;

    if (bin > bin2) {
    bin >>= 7;
    }

    bin2 = bin.RoateLeft(3 );

    if (bin2 != bin) {
    bin2 = bin;
    }

    bin++;
    bin *= "0101";

    you get the picture...

    optimizations wanted. There will be more updates, this is just a preview...

    Thanks,
    Shawn


  • Shawn B.

    #2
    Re: bit manipulation

    "Shawn B." <leabre@html.co m> wrote in message
    news:uOsLL02jDH A.2656@TK2MSFTN GP10.phx.gbl...[color=blue]
    > Greetings,
    >
    > Thanks for helping me with some of the C# bit manipulation issues I've[/color]
    asked[color=blue]
    > about over the last couple days. I've got a first public preview of the
    > Binary8, Binary16, Binary32, and Binary64 classes I've worked on.
    >
    > http://www.visualassembler.com/binary/
    >
    > Use it like you would any other int, short, byte, whatever... I've
    > overloaded all but one of the operators (^ -- don't know how to do so).
    >
    >
    > Examples,
    >
    > Binary8 bin = "10110100";
    > Binary16 bin = "1101";
    >
    > Binary8 bin2 = bin << 3;
    > Binary64 bin3 = "10101";
    > Binary8 bin4 = bin3; // accepable because it doesn't exceed 8 bits
    >
    > Binary8 bin = 0xFF;
    > Binary16 bin2 = ~bin;
    >
    > if (bin > bin2) {
    > bin >>= 7;
    > }
    >
    > bin2 = bin.RoateLeft(3 );
    >
    > if (bin2 != bin) {
    > bin2 = bin;
    > }
    >
    > bin++;
    > bin *= "0101";
    >
    > you get the picture...
    >
    > optimizations wanted. There will be more updates, this is just a[/color]
    preview...[color=blue]
    >
    > Thanks,
    > Shawn
    >[/color]

    It seems I can't get this to work in VB.NET, it won't allow me to assign the
    object and none of the operators work. Guess it's a MC++, C# only solution.
    Anyone have ideas how I can make it work in VB?


    Thanks,
    Shawn


    Comment

    • Juan Gabriel Del Cid

      #3
      Re: bit manipulation

      There is no operator overloading in VB.

      -JG


      Comment

      • Shawn B.

        #4
        Re: bit manipulation

        One of the biggest marketing pushes for .NET is that if you write in one
        language, they are compatible with other languages that target .NET. All
        you have to do is create you're own type with an operator and all of the
        sudden, you're not compatible with other languages that target .NET. I can
        understand that VB.NET doesn't support operator overloading in its syntax,
        but if I overload in MC++ or in C#, I would expect any other language to be
        able to use that object, regardless whether it supports a syntax for
        overloading its own operator. Good thing this project isn't designed to be
        compatible with VB.NET in the first place, or I would have to make an object
        out of this and do everything by means of methods, which is not very
        ..NETish.

        So it seems only the intrinsic, int, long, bool, etc. are supported by
        VB.NET in terms of using operators on them, and all non-MS objects are not
        supported by VB?


        Thanks,
        Shawn

        "Juan Gabriel Del Cid" <jdelcid@atrevi do.nospam.net> wrote in message
        news:e4YGKB5jDH A.964@TK2MSFTNG P10.phx.gbl...[color=blue]
        > There is no operator overloading in VB.
        >
        > -JG
        >
        >[/color]


        Comment

        • Chris R. Timmons

          #5
          Re: bit manipulation

          "Shawn B." <leabre@html.co m> wrote in
          news:#z23jY5jDH A.2244@TK2MSFTN GP12.phx.gbl:
          [color=blue]
          > One of the biggest marketing pushes for .NET is that if you
          > write in one language, they are compatible with other languages
          > that target .NET. All you have to do is create you're own type
          > with an operator and all of the sudden, you're not compatible
          > with other languages that target .NET. I can understand that
          > VB.NET doesn't support operator overloading in its syntax, but
          > if I overload in MC++ or in C#, I would expect any other
          > language to be able to use that object, regardless whether it
          > supports a syntax for overloading its own operator. Good thing
          > this project isn't designed to be compatible with VB.NET in the
          > first place, or I would have to make an object out of this and
          > do everything by means of methods, which is not very .NETish.
          >
          > So it seems only the intrinsic, int, long, bool, etc. are
          > supported by VB.NET in terms of using operators on them, and all
          > non-MS objects are not supported by VB?[/color]

          Shawn,

          Objects written in different .Net languages are compatible if they
          follow the Common Language Specification (CLS) guidelines:

          http://msdn.microsoft.com/library/en-
          us/cpguide/html/cpconcommonlang uagespecificati on.asp

          or

          http://tinyurl.com/qiyg


          Chris.
          -------------
          C.R. Timmons Consulting, Inc.

          Comment

          • Juan Gabriel Del Cid

            #6
            Re: bit manipulation

            > Good thing this project isn't designed to be[color=blue]
            > compatible with VB.NET in the first place, or I would have to make an[/color]
            object[color=blue]
            > out of this and do everything by means of methods, which is not very
            > .NETish.[/color]

            I think you have a misconception about software development... you don't
            write an application in all the available languages that exist. You *use*
            all the languages you have available.

            In .Net you can write in any language you want and have it all be
            compatible. For example, I once had a project where I needed to talk to
            Excel, MQ Series and be a windows service. So, I used VB for the Excel
            interop, managed C++ for the MQ Series bit and wrote the rest in C# (because
            I love C#).

            I hope that clears it up for you,
            -JG


            Comment

            Working...