PICC e negazione

Slave a tutti.. Io dovrei farei il negato di una variabile di tipo Char, praticamente se la mia variabile è:

01100111b deve diventare: 10011000b

Esiste qualche funzione? Grazie

Reply to
Cap4
Loading thread data ...

Non è molto bello dare dello "schiavo" a tutti.... hehe :-)

Nessuna funzione. Esiste l'operatore ~:

char a = 0b01010101; char b = ~a; ==> b = 0b10101010

Di niente ciao Brunix

Reply to
Brunix

Master a te :)

In C il negato logico si fa con l'operatore ~ (ALT+126 su windows se hai la tastiera italiana). Cioè se il dato è nella variabile c, basta che fai: c = ~c;

Ciao

Reply to
Francesco Sacchi

Cap4 ha scritto:

Se non sbaglio, XOR. A=Dato B=11111111 C=A XOR B

Giuliano

--

questo articolo e` stato inviato via web dal servizio gratuito 
http://www.newsland.it/news segnala gli abusi ad abuse@newsland.it
Reply to
JUL

Si, funziona anche così, ma esiste proprio l'operatore ~ che da solo tutto questo. ciao Brunix

Reply to
Brunix

Grazie a tutti per la veloce risp.. Vi pongo anche un altra domanda:

Io ricevo da seriale un dato fatto in questo modo:

Start b0 b1 b2 b3 b4 b5 b6 b7 Parita pari Stop

0 1 0 0 0 1 1 0 0 1 1

non riesco a capire perchè però mi ritrovo in RCREG

b0 b1 b2 b3 b4 b5 b6 b7

0 0 0 1 1 0 0 1

e in RX9D trovo il bit della parità? E' come se b0 slittasse di 1 posizione rientrando poi in b7. E' possibile?

Reply to
Cap4

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.