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

Veröffentlicht

Hallo!

Wie kann ich in C++ ne´ Bitoperation machen?!

Eine Linkssrotation!

also im Byte 1011 1000 soll das letzte Bit nach Links wegrücken! Das letzte soll dann wieder rechts reingeschoben werden.

Danke!!!

MfG

NetzKing

Natürlich macht man sowas mit dem Inline-Assembler:

char zahl=0x81; diese Zahl wird mit nur einem Befehl rotiert

__asm

{

rol zahl,1

}

andersrum wäre: ror zahl,1

Bitrotationen wurden leider gar nicht in C Prozessorkonform berücksichtigt, obwohl jeder Prozessor beschleunigte Standardbefehle für Bitshift&rotate mit und ohne arithmetische Berücksichtigung hat, weshalb es da nur eingeschränkte und alles andere als optimierte Möglichkeiten gibt:

z.B. halt so:

zahl=zahl<<1|(bool)(zahl&0x80);

da kommt aber ein riesen Assembler-Code bei raus:

movsx ecx,byte ptr [ebp-8]

shl ecx,1

movsx edx,byte ptr [ebp-8]

and edx,80h

neg edx

sbb edx,edx

neg edx

and edx,0FFh

or ecx,edx

mov byte ptr [ebp-8],cl

... was doch ein klein wenig länger braucht.

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.