473,382 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

About the SET BIT to set the specific bit in a binary converted ascii value

Respected experts i am doing a project on the basis of c,
For this I need a guidelines.
After converting the ASCII value of the charecter that will be converted
to its binary format till this i did it.but now i want to set the specified bit in that binary format on the basis of this condition.
1)If any bit value which is ANDed to the perticular bit position in the binary format it should set so that

1 2^(bit-1) =2^0 if bit=1
2 2^(bit-2) =2^1
3 2^(bit-3) =2^2
4 2^(bit-4) =2^3

if(N&ch)=N WHERE N is a specific bit.
/*prg to find ascii of a charecter*/

# include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<conio.h>
#include<math.h>

class Bits {

char ch ;

public :
Bits ( char c ) {
ch = c ;
}
void showBits() ;
void setBit ( int ) ;
void operator = ( char c ) {
ch = c;
}
} ;
void Bits::showBits() {
int i,c ;

cout << "\n\n " << ch << "\t" ;

for ( i = 128 ; i >= 1 ; i >>= 1 )
( (i&ch) == i ) ? ( cout << 1 ) : ( cout << 0 ) ;
}



void main()
{

Bits b ('A' ) ;

clrscr() ;

b.showBits() ;

b = 'a' ;

b.showBits() ;

}
o/p:
A=01000001
a=01100001
Feb 7 '08 #1
0 1304

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Bix | last post by:
As this is my very first post, I'd like to give thanks to all who support this with their help. Hopefully, this question hasn't been answered (too many times) before... If anyone could explain...
7
by: Drake | last post by:
Well, I'm stuck in legacy land and I need a helping hand. We're trying to give some modern value-added functionality to a circa-1985 fortran proggie. The program produces a binary file, by...
12
by: Adam J. Schaff | last post by:
I am writing a quick program to edit a binary file that contains file paths (amongst other things). If I look at the files in notepad, they look like: ...
6
by: SandyMan | last post by:
Hi, I am able to open a binary file for reading but can someone tell me as how to go about converting a Binary file to ASCII file using C. Thanks In Advance SandyMan
3
by: Yuri CHUANG | last post by:
Hi, Here is my code, #include<stdio.h> #include<stdlib.h> typedef struct BiTNode { char data; struct BiTNode *lchild,*rchild;
2
by: DBuss | last post by:
OK, I'm reading a multicast socket. It attaches fine, reads fine, all of that. The problem is that while some of the data I get is normal text (ASCII String), some of it is Binary Integer. ...
24
by: Bartc | last post by:
The stdin/stdout files of C seem to be always in Text mode. Is there any way of running a C program so that these (but especially stdout) are in Binary mode instead? (I'm in the process of...
7
by: azrael | last post by:
Hy folks, I googled, and searched, and can not bealive that I have not found a built in way to convert the easy and elegant python way a function to easily convert simple ascii data to binary...
38
by: Bill Cunningham | last post by:
When I want to clear memory space this is what I typically do myself, char a; int i; for (i=0;i != 100;++i) a='\0'; Now with the function memset I could do the same thing and it would be...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.