• # En GO

    Posté par . En réponse au journal Un décalage de 64 bits, ça vous inspire comment ?. Évalué à 6.

     func main() {
     var i uint64
     i = 1
     fmt.Printf("i >> 64 : %d\n", i >> 64)
     }

    Résultat :

    i >> 64 : 0

    Et le résultat est documenté dans la documentation du langage :

    There is no upper limit on the shift count. Shifts behave as if the left operand is shifted n times by 1 for a shift count of n. As a result, x << 1 is the same as x*2 and x >> 1 is the same as x/2 but truncated towards negative infinity.