Shifting by the number of bits in a native integer (or more) is zero, except when the "overshift" is right shifting a negative value under use integer , in which case the result is -1 (arithmetic shift).
Until now negative shifting and overshifting have been undefined because they have relied on whatever the C implementation happens to do. For example, for the overshift a common C behavior is "modulo shift":
1>>64==1>>(64%64)==1>>0==1# Common C behavior.# And the same for <<, while Perl now produces 0 for both.
Now these behaviors are well-defined under Perl, regardless of what the underlying C implementation does.
Jusqu'à la 5.2, Perl se reposait sur l'implémentation en C et le comportement était indéfini; depuis la 5.4, le comportement est bien défini.
Sapere aude ! Aie le courage de te servir de ton propre entendement. Voilà la devise des Lumières.
[^] # Re: Quelques autres
Posté par kantien . En réponse au journal Un décalage de 64 bits, ça vous inspire comment ?. Évalué à 6.
Comme pour les autres, c'est dans la doc :
Jusqu'à la 5.2, Perl se reposait sur l'implémentation en C et le comportement était indéfini; depuis la 5.4, le comportement est bien défini.
Sapere aude ! Aie le courage de te servir de ton propre entendement. Voilà la devise des Lumières.