Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Originally posted by Guybrush Threepwood

Hi,

kann mir einer von euch mal erklären wie die Leftshift und

Rightshift Operatoren genau funktionieren?

Mir ist klar das sie die Bits nach links bzw. rechts verschieben,

aber so ganz blicke ich da trotzdem nicht durch.:(

Gruß

Guybrush

Hmmm vielleicht so:

1000 0000 dann eins nach rechts ist 0100 0000 , da die geschoben werden

und nicht rotiert (soweit ich noch weiss) fielgt dann das rechte raus.

und dann nach links:

0000 0001 -> 0000 0010

Frank

  • 3 Wochen später...
  • Autor

Ja, so hatte ich mir das eigentlich auch gedacht, und wenn ich sowas schreibe:


int i= 1,
t=4;
t <<= i;
[/PHP]

dann ist t danach 8, ist ja auch logisch, das bit wurde um 4 nach links geschoben,

aber wenn mehr wie ein Bit gesetzt sind verstehe ich es nicht mehr.

Warum kommt hier:

[PHP]
int i= 3,
t=4;
t <<= i;

als Ergebnis 32 raus? Es müßte doch 48 sein oder nicht?

Gruß

Guybrush

Originally posted by Guybrush Threepwood

Warum kommt hier:


int i= 3,
t=4;
t <<= i;
[/PHP]

als Ergebnis 32 raus? Es müßte doch 48 sein oder nicht?

Gruß

Guybrush [/b]

Nein, 32 ist schon richtig. Ein Shift nach links um eine Stelle ist im Prinzip (sofern man nicht links "rausshiftet") eine Multiplikation mit 2. In Deinem Beispiel also: 4*(2*2*2).

Nic

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.