Postgres undone bytes when set_bit



  • I have:

    0000 0101 - выбран 2 параметр, он активен
    

    I don't know what I'm asking for.

    0000 1001 - выбран 3 параметр, он активен
    

    request

    select set_bit(5::bit(8), 4, 1)
    

    Come back. 00001101I mean, I'd drop all the first seven battles, and then I'd out the right one.



  • Go with the binary operators. That's right.

    (0000 1001 & 1111 1011) | 0000 1000
    

    It' be that way.

    select (5 & 251) | 8
    

    also depends on the type of variable in your base.

    UPD

    There's a universal option.

    select (5 & ~(1 << 2)) | (1 << 3)
    

    Right here. 5 - is the assigned number (value)

    << 2 - B bat's right number that needs to be removed.

    << 3 - bat number from right to insert

    works with any length.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2