473,396 Members | 1,789 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,396 software developers and data experts.

Comparing Bits....

Hi....

This may sound a bit novice ( because i am), could you please
tell the procedure to compare bits of two different files stored on a
secondary memory......

Thank You....

May 17 '07 #1
11 2196
On 17 May 2007 01:11:07 -0700, Harsha <ha********@gmail.comwrote:
>Hi....

This may sound a bit novice ( because i am), could you please
tell the procedure to compare bits of two different files stored on a
secondary memory......
Clarify please:

What is secondary memory? Files are normally stored on media,
such as a disk.

By bit do you mean a particular binary digit or do you mean a
portion of the file (such as the first ten characters)?
Remove del for email
May 17 '07 #2
On Thu, 17 May 2007 05:27:52 -0700, Barry Schwarz <sc******@doezl.net>
wrote:
>On 17 May 2007 01:11:07 -0700, Harsha <ha********@gmail.comwrote:
>>Hi....

This may sound a bit novice ( because i am), could you please
tell the procedure to compare bits of two different files stored on a
secondary memory......

Clarify please:

What is secondary memory? Files are normally stored on media,
such as a disk.
Secondary memory is storage for data and programs not in use at the
moment. In other words, media such as disk <g>.

Do you have to be old to recognize this term?
>
By bit do you mean a particular binary digit or do you mean a
portion of the file (such as the first ten characters)?
Remove del for email
--
Al Balmer
Sun City, AZ
May 17 '07 #3
On May 17, 1:11 am, Harsha <harsha1...@gmail.comwrote:
Hi....

This may sound a bit novice ( because i am), could you please
tell the procedure to compare bits of two different files stored on a
secondary memory......
Open file 1
Open file 2
readloop:
read a byte from file 1
read a byte from file 2
test0 = byte1 ^ byte2 /* if identical then bytes are identical */
test1 = byte1 & byte2 /* these are the bits that are the same */
end of file? Yes, then done, no then goto readloop

May 18 '07 #4
On Thu, 17 May 2007 21:32:46 GMT, Al Balmer <al******@att.netwrote:
>On Thu, 17 May 2007 05:27:52 -0700, Barry Schwarz <sc******@doezl.net>
wrote:
>>On 17 May 2007 01:11:07 -0700, Harsha <ha********@gmail.comwrote:
>>>Hi....

This may sound a bit novice ( because i am), could you please
tell the procedure to compare bits of two different files stored on a
secondary memory......

Clarify please:

What is secondary memory? Files are normally stored on media,
such as a disk.

Secondary memory is storage for data and programs not in use at the
moment. In other words, media such as disk <g>.
I'll believe that is true for your system. On my system, I have never
heard of disk being referred to as secondary memory. Storage yes but
never memory.

Assuming that secondary memory is memory other that primary memory,
the closest thing on my system is extended memory which is memory not
addressable by an application used by the operating system to hold
portions of virtual memory that are currently not in active use
(inactive data and code that has been paged out of real memory to make
room for data and code that is active).
>
Do you have to be old to recognize this term?
I've only been doing this since the mid 1960's so there must be some
other criterion besides age.
>>
By bit do you mean a particular binary digit or do you mean a
portion of the file (such as the first ten characters)?
Remove del for email

Remove del for email
May 18 '07 #5
JT
On May 18, 12:48 am, Barry Schwarz <schwa...@doezl.netwrote:
On my system, I have never heard of disk being referred
to as secondary memory. Storage yes but never memory.
...
I've only been doing this since the mid 1960's
so there must be some other criterion besides age.
See this snippet from Britannica
http://www.britannica.com/eb/article-235898/computer

"Secondary Memory"
Secondary memory on a computer is storage for data
and programs not in use at the moment. In addition
to punched cards and paper tape, early computers also
used magnetic tape for secondary storage....

So, yes, you have to be old enough to be using
punched cards to recognize this term.

May 18 '07 #6
JT
On May 18, 12:56 am, JT <jackt...@gmail.comwrote:
>
See this snippet from Britannicahttp://www.britannica.com/eb/article-235898/computer

"Secondary Memory"
Secondary memory on a computer is storage for data
and programs not in use at the moment. In addition
to punched cards and paper tape, early computers also
used magnetic tape...
Addendum: the Britannica article is credited to be
authored by Professor David Hemmendinger
of computer science at Union College, Schenectady, New York
May 18 '07 #7
bits in the sense i want to compare each binary bit of one file with
corresponding bit of other file, just forget about "secondary memory"
here...thank you...

May 18 '07 #8
Harsha <ha********@gmail.comwrites:
bits in the sense i want to compare each binary bit of one file with
corresponding bit of other file, just forget about "secondary memory"
here...thank you...
*Please* provide context when you post a followup. Don't assume that
anyone has seen, or can see, the previous article. Read
<http://cfaj.freeshell.org/google/>.

Your original question was:

| This may sound a bit novice ( because i am), could you please
| tell the procedure to compare bits of two different files stored on a
| secondary memory......

You say you want to compare "each binary bit". The word "compare"
doesn't mean much by itself if you don't specify what you want to do
with the result of the comparison. Do you care about whether each
individual bit is equal to the corresponding bit in the other file
(and if so, what do you want to do about it), or do you just want to
know whether the files as a whole are identical?

If you just want to know whether the files are identical, you can read
data from each into a buffer using fread(), and compare the buffers
using memcmp(). If that's not what you're looking for, you'll have to
ask a more specific question.

A concrete example, showing both input and desired output, would be
helpful.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
May 18 '07 #9
On Thu, 17 May 2007 17:48:29 -0700, Barry Schwarz <sc******@doezl.net>
wrote:
>On Thu, 17 May 2007 21:32:46 GMT, Al Balmer <al******@att.netwrote:
>>On Thu, 17 May 2007 05:27:52 -0700, Barry Schwarz <sc******@doezl.net>
wrote:
>>>On 17 May 2007 01:11:07 -0700, Harsha <ha********@gmail.comwrote:

Hi....

This may sound a bit novice ( because i am), could you please
tell the procedure to compare bits of two different files stored on a
secondary memory......

Clarify please:

What is secondary memory? Files are normally stored on media,
such as a disk.

Secondary memory is storage for data and programs not in use at the
moment. In other words, media such as disk <g>.

I'll believe that is true for your system. On my system, I have never
heard of disk being referred to as secondary memory. Storage yes but
never memory.
A system dependent technical term? Fortunately, the meaning of such
terms doesn't depend on what you have heard of. The usage is well
established, though not heard much these days.

Try google for "secondary memory." With the quotes. The first page
returned should convince you, even without following any of the links.

--
Al Balmer
Sun City, AZ
May 18 '07 #10
Harsha wrote:
>
This may sound a bit novice ( because i am), could you please tell
the procedure to compare bits of two different files stored on a
secondary memory......
int c1, c2;
...
do {
while (((c1 = getc(f1) != EOF)) && (c2 = getc(f2) != EOF))
continue;
/* display difference if no EOF */
} while ((c1 != EOF) && (c2 != EOF));

/* untested */

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

May 19 '07 #11
Barry Schwarz wrote:
Al Balmer <al******@att.netwrote:
.... snip ...
>
Assuming that secondary memory is memory other that primary memory,
the closest thing on my system is extended memory which is memory
not addressable by an application used by the operating system to
hold portions of virtual memory that are currently not in active
use (inactive data and code that has been paged out of real memory
to make room for data and code that is active).
>Do you have to be old to recognize this term?

I've only been doing this since the mid 1960's so there must be
some other criterion besides age.
Well, we'll excuse your lack of experience, in deference to your
age. :-)

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

May 21 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Peter | last post by:
Hi how can I compare two byte arrays in VB.NET Thank Peter
1
by: Iain | last post by:
Hi Hopefully I am missing something really simple with this question, but here goes. I have two Bitarrays that I would like to compare. At the moment, I am XORing one with the other and...
6
by: sridhar | last post by:
#include <stdio.h> int main(){ unsigned int ui = 0; if(0x0ul <= ui){ printf("less eq\n"); } } On my system unsigned long is 64 bits and unsigned int is 32.The compiler gives a warning
5
by: John | last post by:
I have two numbers a,b. I would like to compare if most significant bit of a is larger than most significant bit of b. Right now the code I am using looks like this int w1,w2; asm("bsr...
12
by: John Smith | last post by:
This code for the comparison of fp types is taken from the C FAQ. Any problems using it in a macro? /* compare 2 doubles for equality */ #define DBL_ISEQUAL(a,b)...
27
by: Thomas Kowalski | last post by:
Hi everyone, To determine equality of two doubles a and b the following is often done: bool isEqual ( double a, double b ) { return ( fabs (a-b) < THRESHOLD ); } But this a approach usually...
2
byenary
by: byenary | last post by:
Hello I have got 2 variabeles in an application the type; typedef guint32 data; -> so 256 bits Now i have a load of data of this type derrived from fileheaders. I want to compare these and get a...
18
by: eman.abu.samra | last post by:
Hi all, i have encountered the strangest behavior. Check out this simple program: #include <stdio.h> int main() { double time = 1;
17
by: fgh.vbn.rty | last post by:
I know that std::vector<boolis specialized to store individual bools as single bits. I have a question about the comparison operation on a pair of vector<bool>s. Is the comparison done bit by...
5
by: saneman | last post by:
I have a function: int F(double a) { if (a = =1.0) { return 22; } return 44; }
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.