473,473 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Doing binary conversions by hand

8 New Member
I am having a time with these problems:

X=1100110000110011
Y=0000111100001010

1) what would I get in binary representation for X<<5?

2) what is the two's complement of negative Y (-Y)?

3) If X is an int variable, what do we know about the value of X&X?
a. It is always equal to X.
b. It is always greater than 1.
c. It is always equal to zero.
d. It is always equal to 1.
Nov 13 '07 #1
4 1277
sicarie
4,677 Recognized Expert Moderator Specialist
What are you having trouble with? Did you try them? What did you get?
Nov 13 '07 #2
AHMEDYO
112 New Member
HI.,..

i cant understand Q1 fully, but if you wanna all binary values for x < 5 then

Q1: x=000 , 001 , 010 , 011 , 100

Q2: to get the 2's complementer first u reverse all bits 0s to 1s and all 1s to 0s and then additional the result by 1

Y=0000111100001010

1's Complementer =1111000011110101
2's Complementer =0000000000000001

and then add each 2 bits ------------------------------
= xxxxxxxxxxxxxxxx

the result is the 2's complementer for Y or -Y by 2's complementer

Q3: answer is choice A

try to check behind me i cant exactly rememmber all things, but i think it will right answer..

by the way is that home work? :D

GOOD LUCK..
Nov 17 '07 #3
Ganon11
3,652 Recognized Expert Specialist
Q1 isn't asking about the < operator, but the bitshift operator <<, which I believe moves the entire set of bits to the left, creating 0s at the end. For instance,

Expand|Select|Wrap|Line Numbers
  1. X = 0100 1101
  2. X << 2
  3. (X is now 0001 0011 0100)
Of course, I could be wrong.
Nov 17 '07 #4
AHMEDYO
112 New Member
Q1 isn't asking about the < operator, but the bitshift operator <<, which I believe moves the entire set of bits to the left, creating 0s at the end. For instance,

Expand|Select|Wrap|Line Numbers
  1. X = 0100 1101
  2. X << 2
  3. (X is now 0001 0011 0100)
Of course, I could be wrong.
hey..no man i think that you fully right, its SHL operator

Many Thanx
Nov 17 '07 #5

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

Similar topics

0
by: Dan Stromberg | last post by:
I've written up a page about how to convert native binary data to another platform's native binary data, as I did some fortran data conversions for a client. The programs and documentation are...
103
by: Steven T. Hatton | last post by:
§27.4.2.1.4 Type ios_base::openmode Says this about the std::ios::binary openmode flag: *binary*: perform input and output in binary mode (as opposed to text mode) And that is basically _all_ it...
3
by: Tanuki | last post by:
Hi All: I encounter a programming problem recently. I need to read a binary file. I need to translate the binary data into useful information. I have the format at hand, like 1st byte = ID,...
68
by: vim | last post by:
hello everybody Plz tell the differance between binary file and ascii file............... Thanks in advance vim
5
by: Daz | last post by:
Hi everyone! I am very new to casting and converting, so much in fact then when I think I have it figured out, something proves me wrong. I was wondering if there is any logic in 'what types can...
29
by: Harlin Seritt | last post by:
Hi... I would like to take a string like 'supercalifragilisticexpialidocius' and write it to a file in binary forms -- this way a user cannot read the string in case they were try to open in...
3
by: masood.iqbal | last post by:
Hi, Kindly excuse my novice question. In all the literature on ifstream that I have seen, nowhere have I read what happens if you try to read a binary file using the ">>" operator. I ran into...
34
by: raphfrk | last post by:
This program should copy one file onto the other. It works if I compile it with gcc to a cygwin program. However, if I compile it with the -mno-cygwin option, it doesn't work (this targets native...
17
by: Bill Cunningham | last post by:
I was wondering if someone could look this file over for me. It compiles correctly and prints the number 2 so I know fscanf is working. I am reading a text file and converting the text data...
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...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.