To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 1909
1908  |  1910
Subject: 
Re: Somewhat C challenged.
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Thu, 10 Apr 1997 02:48:28 GMT
Original-From: 
Prabal Dutta <(prabal@dmsc.)AvoidSpam(com)>
Reply-To: 
prabal@dmsc.+AvoidSpam+com
Viewed: 
1423 times
  
Victor,

The peek(0x1000) statement returns the byte at memory location 1000
(hex).  In C, the '&' operator is a bitwise AND.  So, what you are doing
is ANDing 4 and the contents of 0x1000.  What's really going on is you
are interested in only bit 3 (out of bits 0 through 7), and the
statement is masking the other bits:

mem(0x1000) = xxxx xxxx
          4 = 0000 0100
          -------------
              0000 0x00

That way you only see the value of bit 3.

- Prabal

victor w clark wrote:

Please excuse my bitwise ignorance. Could someone explain this statement
to me.
if (4 & peek(0x1000))
what does peek(0x1000) return?
what is the 4 for ?
and what does the "&" compare?

thanks
victor

--
Prabal Dutta                               Tel:    (614) 299-2566
Digital Micro Systems, Corp.               FAX:    (614) 299-2939
PO Box 3579                                e-mail: prabal@dmsc.com
Columbus OH 43210-0579                     WWW:    http://www.dmsc.com



Message is in Reply To:
  Somewhat C challenged.
 
Please excuse my bitwise ignorance. Could someone explain this statement to me. if (4 & peek(0x1000)) what does peek(0x1000) return? what is the 4 for ? and what does the "&" compare? thanks victor (27 years ago, 9-Apr-97, to lugnet.robotics.handyboard)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR