Compliment Data

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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/...

#2 Hardware Problem? Read AVR042.

#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."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
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

 

Just don't flip your lid

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
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


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/...

#2 Hardware Problem? Read AVR042.

#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."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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:

 

About 38,700,000 results (0.51 seconds)

 

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
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Thank you so much  avrcandies  , it worked .

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

hey! zaheerudin ,  

Is your code working? show me how it works. 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1


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

 

Something like this:

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Two's complement, three's a crowd.

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

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

Please Read: Code-of-Conduct

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

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

three's a crowd

 

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

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How do you know they are twins?

Iluvatar is the better part of Valar.