J'utilise une technologie appelée DDS et dans l'IDL, elle ne prend pas en charge int
. Donc, je me suis dit que je voudrais juste utiliser short
. Je n'ai pas besoin de tant de bits. Cependant, quand je fais ceci:Opérations bit à bit sur court
short bit = 0;
System.out.println(bit);
bit = bit | 0x00000001;
System.out.println(bit);
bit = bit & ~0x00000001;
bit = bit | 0x00000002;
System.out.println(bit);
Il dit "incompatibilité de type: Impossible de convertir de int à court". Quand je change short
en long
, cela fonctionne très bien.
Est-il possible d'effectuer des opérations au niveau du bit comme ceci sur un short
en Java?
Voilà, merci. –