हिंदी माध्यम नोट्स
Categories: C Language in hindi
Bitwise Operators : Shift or complement in hindi , बिट वाइज ऑपरेटर : शिफ्ट या कॉम्प्लीमेंट c कंप्यूटर भाषा हिंदी में
बिट वाइज ऑपरेटर : शिफ्ट या कॉम्प्लीमेंट c कंप्यूटर भाषा हिंदी में Bitwise Operators : Shift or complement in hindi :-
इससे पहले article मे,हमने bitwise लॉजिकल operator को पढ़ा |इस article मे , हम bitwise shift और complement operator को पढेगे |
Bitwise shift Operator
इस operator का use किसी बिट पैटर्न मे left या right side मूव करने के लिए किया जाता है |shift operator का syntax >> और << है | इसका syntax है :-
left side : operand << n
right side : operand >>n
यहा पर
operand : कोई integer है जिसके बिट पैटर्न मे shifting होनी वाली है |
n: ये number ऑफ़ bits है जो बिट पैटर्न मे shift होगे |
left bit operator , किसी pattern के सभी bits को left side मे n position तक shift कर देते है |किसी पैटर्न की left most बिट खो सकती है उसके स्थान पर shifted bits आ सकती है |और right side हुई vacant जगह को ‘0’ से filled कर दे जाती है |
right shift operator , किसी pattern के सभी bits को right side मे n position तक shift कर देते है |किसी पैटर्न की right most bit खो सकती है उसके स्थान पर shifted bits आ सकती है |और
अगर integer unsigned होता है तब left side हुई vacant जगह को ‘0’ से filled कर दे जाती है |
अगर integer signed होता है तब vacant जगह की value machine पर निर्भर करती है |
दोनों ही operand और n, constant और variable हो सकती है |लेकिन n की value मे दो limitation हो सकती है :-
1.’n’ की value negative नहीं हो सकती है |
2.’n’ की value किसी integer के भीत पैटर्न मे स्थित bits से ज्यादा नहीं हो सकती है |
उदाहरण के लिए :
a एक unsigned integer है जिसका बिट पैटर्न है 0110 0011 1011 1000
a<<3 : 0101 1101 1100 0000
a>>3 : 0000 1100 0111 0111
a<<3 statement से बिट पैटर्न तीन position left side मे move हो गया |इसलिए बिट पैटर्न के पांच right position पर ‘0’ आ जाता है |
a>>3 statement से बिट पैटर्न 3 position right side मे मूव हो गया|इसलिए बिट पैटर्न के पहले तीन vacant positions पर ‘0’ आ जाता है |
shift operator का use , 2 से multiplication और division के लिए करते है |
उदाहरण -1
#include<stdio.h>
#include<conio.h>
void main()
{
{
int a;
printf(“Enter Value”);
scnaf(“%d”,&a);
b=a<<1;
printf(“Output = %d”,b);
getch();
}
इस उदहारण का आउटपुट होगा :
Enter Value 12
Output 24
बिट पैटर्न मे , 12 : 0000 1100
after shifting , 0001 1000 जो की 24 का बिट pattern है |
अतः इस प्रोग्राम से , हम यूजर द्वारा दिए गये input को 2 से multiply कर सकते है |
उदाहरण -2
#include<stdio.h>
#include<conio.h>
void main()
{
{
int a;
printf(“Enter Value”);
scnaf(“%d”,&a);
b=a>>1;
printf(“Output = %d”,b);
getch();
}
इस उदहारण का आउटपुट होगा :
Enter Value 12
Output 6
बिट पैटर्न मे , 12 : 0000 1100
after shifting , 0000 0110 जो की 6 का बिट pattern है |
अतः इस प्रोग्राम से , हम यूजर द्वारा दिए गये input को 2 से divide कर सकते है |
Bitwise Complement operator
इस operator का use किसी एक operand पर हो सकता है |इसे किसी integer के बिट पैटर्न को complement करने के लिए किया जाता है |इसका मतलब है :-
सभी ‘1’ ,’0′ मे change हो जाये |
और सभी ‘0’ ,’1′ मे change हो जाये |
उदाहरण के लिए :
bit pattern : 0111 1010
Output : 1000 0101
इसका syntax ‘~’ है |
Masking
masking एक प्रोसेस है जिसमे किसी बिट पैटर्न मे से specific bits को extract किया जाता है |masking प्रोसेस मे लॉजिकल operator के अलावा shift operator को भी use कर सकते है |जिस operand पर masking होती उसे mask कहते है |
उदाहरण के लिए
b=a & mask;
b=a | mask;
masking का use :
1. masking का use किसी integer के बिट पैटर्न को decide करने के लिए किया जाता है |
2. किसी बिट पैटर्न के portion को दुसरे variable मे copy करना और पुरने वाले बिट पैटर्न मे vacant place पर ‘0’ place करना |
3. किसी बिट पैटर्न के portion को दुसरे variable मे copy करना और पुरने वाले बिट पैटर्न मे vacant place पर ‘1’ place करना |
4.किसी बिट पैटर्न के portion को दुसरे variable मे copy करना और पुरने वाले बिट पैटर्न मे बचेर हुए बिट को invert करना |
उदाहरण के लिए :
दो इनपुट्स है (i) 101001 (ii) 001100 |इन input से 001000 बिट पैटर्न चाहिए |ये तभी हो सकता है जब दोनों input का OR operation हो |इसका code है:-
दो इनपुट्स है (i) 101001 (ii) 001100 |इन input से 001000 बिट पैटर्न चाहिए |ये तभी हो सकता है जब दोनों input का OR operation हो |इसका code है:-
#include<stdio.h>
#include<conio.h>
void main()
{
{
int a,b,c;
printf(“Enter Value”);
scnaf(“%d”,&a &b);
c=a|b;
c=a|b;
printf(“Output = %d”,c);
getch();
}
इस उदाहरण का आउटपुट होगा : 001000इस प्रकार दो या दो से अधिक bitwise operator को use करके ,प्रोग्रामर desired आउटपुट प्राप्त कर सकता है |इस प्रोसेस को Masking कहते है |
Recent Posts
सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है
सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…
1 day ago
मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the
marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…
1 day ago
राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi
sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…
3 days ago
गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi
gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…
3 days ago
Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन
वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…
3 months ago
polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten
get all types and chapters polity notes pdf in hindi for upsc , SSC ,…
3 months ago