Save
Forgot Password
Register Here
Resources
Applications
AI
Business
Components and Libraries
Computer Science
Database
Documents And Specifications
Enterprise Application Integration
Game
Hardware
Multimedia
Network
Security
Tools And Utilities
Training And Certification
Web
Languages
Assembly
Basic
C
C#
C++
Delphi
Java
JavaScript
Other Languages
Pascal
Perl
PHP
Python
Ruby
VB-Script
Visual Basic
Platforms
.NET
Browser Based
Consoles
CPU
Embedded
Java Platform
Legacy Platforms
Linux
Macintosh
Mobile Platforms
MS-DOS
Remotely Hosted
UNIX
WEB Service
Windows
Forums
Unanswered Posts
Latest Threads
Latest Posts
Programming Languages
Assembler Developer
Basic
C and C++
C#
Delphi and Kylix
Java
Pascal
Perl
PHP
Python
Ruby
VB.NET
VBA
Visual Basic
Applications
Computer Graphics
Computer Hardware
Database & SQL
Electronics development
Game programming
Matlab
Sound & Music
XML Development
Classifieds
Co-operative Projects
For sale
FreeLance Software City
Jobs Available
Jobs Wanted
Wanted
Microsoft .NET
.NET General
ASP.NET
Miscellaneous
Comments on the PH Re-design
Comments on this site
Computer Emulators
General programming
New programming languages
Off topic board
Mobile & Wireless
Palm Pilot
Multimedia
Demo programming
MP3 programming
Operating Systems & Platforms
Cloud Computing
Embedded / RTOS
FreeBSD
LINUX programming
MS-DOS
Windows CE & Pocket PC
Windows programming
Software Development
Algorithms
Object Orientation
Project Management
Quality & Testing
Security
WEB-Development
Active Server Pages
AJAX
CGI Development
ColdFusion
Flash development
HTML & WEB-Design
Internet Development
JavaScript
WEB Servers
WEB-Services / SOAP
Blogs
Blog Startpage
Latest Blog Posts
Submit
Article
Book
File
Link
News
PAD File
Wiki Article
Jobs
Dev Tools
PH
Search
Newsletter
Merchandise
Top User Lists
Getting Started Guide
Help
Advertise
Contact Us
HOME
>
Forums
>
C and C++
> Two memory locations M1 and M2, contain 32 bit...
C and C++
Moderators: None (
Apply to moderate this forum
)
Number of threads:
28629
Number of posts:
94611
With full replies
Topics only
C and C++
Subforums
Forum Info
This Forum Only
Single Post View
Linear View
Threaded View
f
Printer Friendly
RSS Feed
Two memory locations M1 and M2, contain 32 bit values.
Posted by
smilingsheshu
on 15 Dec 2008 at 5:30 AM
Two memory locations M1 and M2, contain 32 bit values.
Write a program to compare the 3 bit values ( bit19,bit18,bit17)of M1
with 3 bit values ( bit9,bit8,bit7) of M2 and print EQUAL if they are equal
Share By Email
Re: Two memory locations M1 and M2, contain 32 bit values.
Posted by
Malcolm_McLean
on 15 Dec 2008 at 5:37 AM
: Two memory locations M1 and M2, contain 32 bit values.
: Write a program to compare the 3 bit values ( bit19,bit18,bit17)of M1
: with 3 bit values ( bit9,bit8,bit7) of M2 and print EQUAL if they
: are equal
:
It's a bit of a bad question, because a program cannot compare two memory locations, unless it has access to core memory it doesn't own.
I suspect the teacher means "input two 32 it numbers".
long is guaranteed to be at least 32 bits. So you can use scanf("%ld" ...) to input the numbers.
Then use the and (&) and shift (>>) operators to manipulate your bits, and printf() to output the result.
Share By Email
Re: Two memory locations M1 and M2, contain 32 bit values.
Posted by
Lundin
on 16 Dec 2008 at 12:59 AM
: It's a bit of a bad question, because a program cannot compare two
: memory locations, unless it has access to core memory it doesn't own.
Nobody said "Windows"!
Share By Email
Re: Two memory locations M1 and M2, contain 32 bit values.
Posted by
Ed Hall
on 15 Dec 2008 at 9:49 AM
This seems rather simple on a 32 bit machine and compiler:
Use unsigned int and grab the two values
Create two masks to isolate the important bits
Use bitwise and & to modify the two values
Use bitwise shift << or >> to move one or the other value 10 bits
(Or, you could simply multiply or divide by the appropriate value)
Use simple if() to compare the new values
It should only take about seven actual lines of code.
Take Care,
Ed
Share By Email
Recent Jobs
Home
About PH
Privacy Statement
Hosted SubVersion
Hosted Bugtracker
Contact Us
Advertise Here
Official Programmer's Heaven Blogs
Web Hosting
|
Browser and Social Games
|
Gadgets
Popular resources on Programmersheaven.com
Assembly
|
Basic
|
C
|
C#
|
C++
|
Delphi
|
Flash
|
Java
|
JavaScript
|
Pascal
|
Perl
|
PHP
|
Python
|
Ruby
|
Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our
Terms Of Use
and
Privacy Statement
for more information.
Operated by
CommunityHeaven
, a
BootstrapLabs
company.