Results 1 to 3 of 3

Thread: Bit Stuff

  1. #1

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    I have a DWORD variable and i want to know the value of the least significant bit and the one next to him .How can i acomplish this.
    Thanks!
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    unsigned long x = 0xffffffff;
    
    unsigned char y = x & 0x1;
    // or (depends on architecture)
    unsigned char y = x & 0x80000000;
    Depending on whether the compiler decides to do any playing around with your endians (as it were)...

    [Edited by parksie on 11-20-2000 at 04:40 PM]
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    This ought to work, oughtn't it? (is that even a word?)

    Code:
    y = your_variable;
    y <<= 31;
    y >>= 31;
    Harry.

    "From one thing, know ten thousand things."

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