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.

Byte in Bit-Array

Empfohlene Antworten

Veröffentlicht

Hallo Community,

wie kann ich ein Byte in ein Bit-Array umwandeln?

Funktioniert das so:

void convertByteToBitArray(UINT8 uc_byte, BIT *b_convByToB[]) {

    UINT8 uc_c = 0;

    for (uc_c = 0; uc_c < 7; uc_c++) {

        b_convByToB[uc_c] = uc_byte << (uc_c + 1);

    }

}

oder so ähnlich ?

#include <iostream>

#include <bitset>

using namespace std;


bitset<8> ToBits(unsigned char byte)

{

    return bitset<8>(byte);

}


int main()

{

    unsigned char byte=1|(1<<3)|(1<<6)|(1<<7);


    bitset<8> my_bset=ToBits(byte);


    cout << my_bset[0];

    cout << my_bset[1];

    cout << my_bset[2];

    cout << my_bset[3];

    cout << my_bset[4];

    cout << my_bset[5];

    cout << my_bset[6];

    cout << my_bset[7] << endl;


    cout << "\nhit enter to quit...";

    cin.get();

}

Verwende die std strukturen :D

Ich würde an deiner stelle immer liber den standard benutzen als irgendwelche libs. Außer es geht nicht anders.

mfg synonym

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.