Results 1 to 3 of 3

Thread: Bitwise Operations ???

  1. #1

    Thread Starter
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    Bitwise Operations ???

    VB Code:
    1. Dim decValue as Decimal = cDec(2^3+2^4+2^2+2^0)
    2.  
    3. If DecValue = (decValue And 2^4) Then
    4.       'Fifth bit set
    5.       Msgbox "Bit 5 is set"
    6. End if

    This gives me a conversion error with Option Strict On

    Do bitwise operators only work with Longs??
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    If DecValue = (decValue And 2^4) Then
    This is just a guess. I have not tried this, but I think That should propably be If DecValue = (decValue And cDec(2^4)) Then
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  3. #3
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    What is it that you're trying to do? It's very unusual to be doing bitwise operations on decimals. If you think about the way that decimals are stored in memory you'll see what I mean. Using the correct casting you should be able to get rid of your Option Strict errors, but I'm still not sure that your code is going to make a lot of sense.
    This world is not my home. I'm just passing through.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width