Wrox Programmer Forums
|
BOOK: Ivor Horton's Beginning Visual C++ 2005
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2005 by Ivor Horton; ISBN: 9780764571978
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 1st, 2006, 04:56 PM
Registered User
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Truth table?

Page 82. How to read the truth table. Which column has the results, (left or right). Where are the two bits = 1, and the result?

Thanks

Lou

 
Old August 1st, 2006, 08:04 PM
Authorized User
 
Join Date: May 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You take one input from the top row and one input from the left hand column to give you an intersection with the output/result. E.g., if you take the '1' as an input in the top row, with the '1' in the left hand column as the second input, the answer is in the bottom right hand 'box', i.e. '1'.

If you had taken the '1' in the top row, with the '0' in the left hand column, the answer is in the 'box' above the bottom right hand 'box', i.e. '0'.

Hope this helps.

 
Old August 2nd, 2006, 09:37 AM
Registered User
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am not following. What if we look at it like this. There are three rows and three columns. Going from left to right, from top to bottom, there are 9 fields. Field one has "bitwise OR", field two '0', field three '1', field 4 '0', etc. Please equate input field #'s to the output field #.

Thanks.

Lou.
 
Old August 2nd, 2006, 01:28 PM
Authorized User
 
Join Date: May 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK. "bitwise OR" is on page 84, rather than 82, but I will describe the operation on the bitwise OR.

You suggested:
>> Field one has "bitwise OR", field two '0', field three '1', field 4 '0',

Hence reading along the rows:
Field 1 "bitwise OR", Field 2 has '0', Field 3 has '1',
Field 4 '0', Field 5 has '0', Field 6 has '1',
Field 7 '1', Field 8 has '1', Field 9 has '1',

Going back to my answer, the two inputs are split into pairs of logic states, which can be either logic '0' or logic '1'. Hence the first pair corresponds to fields 2 and 3. The second pair of logic states, which again can be either logic '0' or logic '1', corresponds to fields 4 and 7.

There is one actual output, i.e. the result, and this corresponds to one of fields 5,6,8 and 9.

By the way, the logic for a bit-wise OR is that if either input is at logical state '1' then the output is at logical state '1'.


As an example, suppose we are comparing two bits and let us call them bit_a and bit_b. We could let bit_a correspond to fields 2 and 3, depending upon whether it is at logic '0' or '1', and then bit_b will correspond to fields 4 and 7, again depending upon whether it is at logic '0' or '1'.

So, if bit_a is '0', then we use field 2; but if bit_a is '1', we use field 3.

For bit_b, if it is '0' then we use field 4 and if it is '1' we use field 7.

Reading down the column for bit_a and along the row for bit_b, we arrive at the intersection of the column and the row, which gives us one of the following fields: 5,6,8 or 9, which gives us our result.


(For the bitwise AND, the logic is that the result is '1' only if both inputs are '1'.)


I hope that this helps you.

(I apologise for using the term boxes, rather than fields; I did think about it afterwards, but as it was 2am when I replied to you...)




 
Old June 4th, 2007, 02:43 AM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

With the Bitwise AND, you line up the binary 8 bit values for the two things you are comparing. If in a bit position there are ones in both, then it is a 1 in your new value. Otherwise, 0's. With INCLUSIVE OR you compare the values in similar positions and if you have a 1 in either (or both) of the values you are working with, it is a 1 in the new value, and a 0 if it's a 0 in that place in both values. With EXCLUSIVE OR, you again compare the binary 8 bit representation for both values, and in this case you have a 1 where there is a 1 in either the first or second value you are working with, but a 0 if there is 1's in both, or 0's in both. (literally, Exclusive OR means 1 if there is a 1 in EITHER ...but NOT both or none..for that bit position)

Ok, I don't know if that helped or not. I'm responding to this topic because this section Lou is asking about pissed me off. So far I've found it a very good book, except when it got to bit manipulation. I did not find it clear that we were working with binary. Once it was obvious to me that the examples he was giving were in binary, so that 'A' or 'Z' were 65 and 90 in decimal, and 0100 0001 and 0101 1010 in binary, respectively, I could understand what we were working with.

SO I figured out how to convert the decimal value of a character in the ASCII set to binary, how to use bit manipulation to work with the binary values of these ASCII characers. It was work but it made me wonder "Is he (Ivor Horton) trying to make me (the reader), think or is he just showing off?"

But then he got to negative binary numbers without even explaining hardly any of what I had to figure out to work through his examples. What I learned (outside of the book, which wasn't explaining binary much at all), is that there are THREE types of ways to indicate negative numbers in binary...there is the signed kind where you just put a 1 at the beginning of the binary number to indicate negative...there is one's complement where you flip the bits...and two's complement...which is like one's complement...only you subtract one and flip the bits... (flip the bits = 1's become 0's and 0's become 1's) And you can't very well figure out what a negative number in binary is if you don't know the convention that is being used.

BUT... his example where -104 is 1001 1000...is wrong. He VERY briefly indicated he was using signed bits as the convention to indicate negative numbers... but 1001 1000 where the leftmost bit is not holding a value but showing the sign...would be -24.

I like that I had to do my own research to understand this part of the book, as that it was probably very good for me to do so. But if you're going to go into complex and esoteric stuff in a book for beginner's, you better at least damn sure have accurate examples for the harder concepts you aren't even explaining much at all.

Thank you.

Rogue Tomato






Similar Threads
Thread Thread Starter Forum Replies Last Post
very urgent:cals table to indesign table using xsl franklinclinton XSLT 1 December 16th, 2009 03:48 PM
Populate a List Box with Table Names & Table date hewstone999 Access VBA 1 February 27th, 2008 10:10 AM
Can a Make Table Query produce a Linked table? kronik Access 5 May 16th, 2006 06:17 AM
(oracle 8i)Alter Table <table> coalesce partition combo Oracle 3 October 13th, 2004 09:35 AM
size of table (type table is table of number) MikoMax Oracle 1 November 19th, 2003 03:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.