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

Doing binary conversions by hand

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 1274
sicarie
4,677 Expert Mod 4TB
What are you having trouble with? Did you try them? What did you get?
Nov 13 '07 #2
AHMEDYO
112 100+
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 Expert 2GB
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 100+
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.