473,402 Members | 2,072 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,402 software developers and data experts.

Have a problem in finding the output of an program.

Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.     unsigned int m = 32;
  4.     printf("%x\n", ~m);
  5.     return 0;
  6. }
  7.  
where int is 32 bits
can u explain how the 32 stored in a memory
according to me:-
-------------------
binary no-100000
here is only 6 bit
can u explain the representation of "32" in 32 bits form in a memory

by the way the ans of this :-ffdf

please explain why this ans comes
Jun 14 '10 #1
3 1427
Dheeraj Joshi
1,123 Expert 1GB
In 6 bit 32 looks like 100000
In 32 bit it looks like (0)0000000000000000000000000100000

Where 0 within the ( ) indicates the sign bit.

And output must be
Expand|Select|Wrap|Line Numbers
  1. ffffffdf
  2.  
~ operator does the bitwise complement(1's complement). i.e all the bits in an expression will be flipped.

Regards
Dheeraj Joshi
Jun 14 '10 #2
@dheerajjoshim
can u reply in stepwise way how this ans comes..
Jun 14 '10 #3
donbock
2,426 Expert 2GB
You should familiarize yourself with the bitwise operators. (Notice that the referenced article is about the operators, not how to express them in any particular computer language.)

You should familiarize yourself with two's-complement representation of binary numbers. The C Standard does not mandate two's-complement representation, but that is by far the most common representation. It is clear from the "correct answer" that your machine uses two's-complement.
Jun 14 '10 #4

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

Similar topics

3
by: Jerry | last post by:
I've found a problem with exec, passthru, shell_exec & system. I'm trying to run the following exec("sort -r -n -k2,2 r1.txt > r2.txt") with r1.txt being a numeric file. The file looks like...
3
by: Suri | last post by:
hi im trying to run this simple program. any help shall be appreciated ..pls see error message. #include <math.h> #include <stdio.h> #include <stdlib.h> int main() { double pic; pic= 4.0 *...
1
by: Pål Johansen | last post by:
I made a program that does screen scraping from a website, but when running this progran on a Win 2003 server the httpwebrequest works fine for a while but suddenly never returns from the request...
1
by: | last post by:
i have problem about mediaplayer.filename i want my program read songs from a drive(c:\mysongs\?) please help me what i type ?
0
by: erkidevries | last post by:
Problem compiling Tkinter program with bmp images (using py2exe) I have a Tkinter gui program that uses bmp as backgrounds. The program itself works when I run from the source. I placed the...
6
by: ashishnh33 | last post by:
cud any one tell me what is the problem in this program #include<iostream.h> #include<conio.h> #include<stdlib.h> int binarysearch(void) int linearsearch(void) class search { private:...
1
by: vera esaulova | last post by:
I have problem whis Windows Media Services 9 Series. I have videostream, which will consist of two streams(512k/bit and 256k/bit).I need to allocate a stream 256k/bit. In SDK is written: ...
1
by: southparkcab | last post by:
# include <stdio.h> # include <stdlib.h> # include <math.h> # define M_SQRT /* macro to insert blank lines on screen */ #define BLANK_LINE(n) {int i=0;for(i<(n);i++)fprintf(stderr,"\n";} ...
1
by: hrubesh | last post by:
Hi, I am having a problem finding the right location of a control if it is found on a form that is on an MDI parent. On mouse click, i want to bring out a "pop up window" that will display extra...
11
by: viki1967 | last post by:
Problem with output text Hi all. I have this page ASP: <!-- #include virtual="/include/conn_mysql.asp"--> <%
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.