## Compliment Data

15 posts / 0 new
Author
Message

Hey

I need help in a code .

I have prepared a code to just get data from switches and store at Port B ,but I don't know how to compliment that data?

anybody can guide?

Here is code:

#include "avr/io.h"
int main(void)
{
DDRB=0xFF; // Output
DDRC=0x00; // Input
while(1)
{
char z=PINC;
PORTB=z;

}
return 0;

Last Edited: Sun. Aug 30, 2020 - 07:40 PM

The spelling is 'complement' which is probably why any web search is not giving you any answers.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

Google did it automatically :) but didn't got any solution

Operators Meaning of operators
& Bitwise AND
| Bitwise OR
^ Bitwise exclusive OR
~ Bitwise complement
<< Shift left
>> Shift right

you want to flip all the bits ~     for a byte  you could also xor with 0xFF

Assume A = 60 and B = 13 in binary format, they will be as follows −

A = 0011 1100

B = 0000 1101

-----------------

A&B = 0000 1100

A|B = 0011 1101

A^B = 0011 0001

~A = 1100 0011

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. Aug 29, 2020 - 08:15 AM

zaheerudin wrote:

Google did it automatically :) but didn't got any solution

Odd, google gives me over 66 million results...

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

Brian Fairchild wrote:
Odd, google gives me over 66 million results...

Perhaps you should post your search term. I entered c code compliment but only got About 38,700,000 results:

Did you mean: c code complement

Search Results

Featured snippet from the web

One's Compliment Operator in C

• It is denoted by ~
• Bit Pattern of the data can be Reversed using One's Compliment.
• It inverts each bit of operand .
• One's Compliment is Unary Operand i.e Operates on 1 Argument.

I do wonder sometimes why if posters can get an answer in 0.51 seconds, they post the question here on freaks and wait for a reply.

Last Edited: Sat. Aug 29, 2020 - 09:27 AM

Thank you so much  avrcandies  , it worked .

hey! zaheerudin ,

Is your code working? show me how it works.

"compliment data?"
.
As in "data you look quite ravishing this evening"?

clawson wrote:
As in "data you look quite ravishing this evening"?

Something like this:

Two's complement, three's a crowd.

Four legs good, two legs bad, three legs stable.

John_A_Brown wrote:
Two's complement, three's a crowd.

4 is too many, and 5's not allowed

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

"The critical shortage here is not stuff, but time." - Johan Ekdahl

"Step N is required before you can do step N+1!" - ka7ehk

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

clawson wrote:
"compliment data?"
.
As in "data you look quite ravishing this evening"?

No.  Compliment data is a tabulation of how many compliments are received each day.

[or given?]

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

three's a crowd

Well, usually so, unless of course the other two happen to be twins!