Results 1 to 4 of 4

Thread: Unary &~

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    202

    Unary &~

    How do I find the address-of the one's complement of 15 (&~15 (C++ code)) in VB? At least I think that's how it is said.

    Thanks

  2. #2
    jim mcnamara
    Guest
    I know C, but I'm finding that people asking for C stuff out of context means that I usually give a bad answer.

    Post the code you got this from.

    To answer your question -
    Code:
    Dim a as long
    a = 15
    z = varptr(a)
    z is now a pointer to a
    If this is for a function call, pass z ByVal.

    I'm not sure how to do a one's complement with VB.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    202
    Here is the code:

    Code:
    bmp.bmWidthBytes = ((bmp.bmWidth + 15) &~15)/8;
    And I saw somewhere were perhaps a one's complement can be acheived some how with Not?

    Thanks

  4. #4
    jim mcnamara
    Guest
    Oh. That's what I thought.

    Code:
    ((bmp.bmWidth + 15) &~15)/8;
    
    should be:
    ((bmp.bmWidth + 15) &  ~15)/8;
    which is
    ( bmp.bmwidth + 15)  and  one's complement of 15
    not the address of.
    You are right, not does give one's complement, except in VB I"ve gotten wierd results. If you want to assume not will work-- this is your code:
    Code:
     dim i as long
     i=   (bmp.bmwidth + 15)  and ( not 15)
     i = i/8
     bmp.bmWidthBytes = i

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