Shaare your links...
5128 links
yakmoijebrille Home Login RSS Feed ATOM Feed Tag cloud Picture wall Daily
Links per page: 20 50 100
page 1 / 1
1 results for tags not x
  • math - Python: unsigned 32 bit bitwise arithmetic - Stack Overflow
    Petite astuce en python pour faire un «not». Le symbole '~' inverse les bits d'un nombre ... sur 32bits signé !
    Or on peut vouloir le faire sur un mot plus petit et surtout non signé. Pour cela il suffit de masquer le nombre avec des '1' de la longueur que l'on veut. Par exemple je veux inverser 0x01 sur 8bits :
    In [26]: "{:08b}".format(0x01)
    Out[26]: '00000001'

    Si je fait simplement '~' je n’obtiens pas le résultat voulu :
    In [27]: "{:08b}".format(~0x01)
    Out[27]: '-0000010'

    Si je masque avec 0xff (8 bits à '1') :
    In [28]: "{:08b}".format(~0x01&0xff)
    Out[28]: '11111110'

    Ça marche.
    Tue Sep 18 09:48:32 2018 - permalink -
    - https://stackoverflow.com/questions/210629/python-unsigned-32-bit-bitwise-arithmetic
    binaire not python
Links per page: 20 50 100
page 1 / 1
Shaarli 0.0.41 beta - The personal, minimalist, super-fast, no-database delicious clone. By sebsauvage.net. Theme by idleman.fr.