473,396 Members | 1,859 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.

HELP please

HI,
I am learning javascript, and at the moment I am working on truth
tables. Can someone please tell me, is "NOT A AND B" the same as "NOT A
AND NOT B". Thanks
Jul 23 '05 #1
8 1156
Cyberdog <da**********@INVALID.com> writes:
I am learning javascript, and at the moment I am working on truth
tables. Can someone please tell me, is "NOT A AND B" the same as "NOT A
AND NOT B".


What are their truth tables?

A | B | NOT A | NOT B | NOT A AND B | NOT A AND NOT B
------+-----+-------+-------+-------------+-----------------
1: true |true | false | false | false | false
2: true |false| false | true | false | false
3: false|true | true | false | true | false
4: false|false| true | true | false | true

Remeber that the truth table for AND has true only when both
operands are true. For NOT A AND B, that happens when both the
NOT A and the B columns are true, which is row 3. For NOT A AND
NOT B, both NOT A and NOT B are true in row 4.

Since the two expressions have different truth tables, they are
not the same.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2
On Thu, 13 May 2004 20:13:10 +0200, Lasse Reichstein Nielsen
<lr*@hotpop.com> wrote:
What are their truth tables?

A | B | NOT A | NOT B | NOT A AND B | NOT A AND NOT B
------+-----+-------+-------+-------------+-----------------
1: true |true | false | false | false | false
2: true |false| false | true | false | false
3: false|true | true | false | true | false
4: false|false| true | true | false | true

Remeber that the truth table for AND has true only when both
operands are true. For NOT A AND B, that happens when both the
NOT A and the B columns are true, which is row 3. For NOT A AND
NOT B, both NOT A and NOT B are true in row 4.

Since the two expressions have different truth tables, they are
not the same.

Hi,
Thanks for that, It would seem that "NOT ( A AND B)" is actually
equivalent to "(NOT A OR NOT B)" Thanks for your help.I think I am just
starting to grasp this.
Jul 23 '05 #3
Cyberdog wrote on 13 mei 2004 in comp.lang.javascript:
I am learning javascript, and at the moment I am working on truth
tables. Can someone please tell me, is "NOT A AND B" the same as "NOT A
AND NOT B". Thanks


[much more basic boolean than javascript]

Not A And B -> false unless A=false and B=true

this is is the same as:

(Not A) And B -> false unless A=false and B=true

and different from:

Not (A and B) -> false only when A and B are true

====================================

(Not A) and (Not B) -> false unless both A and B are false

is the same as:

Not (A or B) -> false unless both A and B are false

Nota Bene: when taking the Nots out of the "()" the "and" changes to "or"

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #4
Cyberdog <da**********@INVALID.com> writes:
Thanks for that, It would seem that "NOT ( A AND B)" is actually
equivalent to "(NOT A OR NOT B)"


It is. That's called de Morgan's law, IIRC. The other way also
holds:
NOT (A OR B) is equivalen to (NOT A) AND (NOT B)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #5
Hi Lasse;

But in some computer languages these two statements are NOT the same because
the NOT operator sometimes takes precedence over the AND operator (it's one
level up in the hierarchy) and NOT A AND B is processed as (NOT A) AND B.

However, being fairly new to javascript, I can't seem to find any precedence
guidelines in the books I currently have. I wrote the attached HTML file
which shows (unless I made a mistake in my javascript coding) that these two
statements *are not* the same.
Charles...
"Cyberdog" <da**********@INVALID.com> wrote in message
news:ji********************************@4ax.com...
HI,
I am learning javascript, and at the moment I am working on truth
tables. Can someone please tell me, is "NOT A AND B" the same as "NOT A
AND NOT B". Thanks
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:1x**********@hotpop.com... Cyberdog <da**********@INVALID.com> writes:
I am learning javascript, and at the moment I am working on truth
tables. Can someone please tell me, is "NOT A AND B" the same as "NOT A
AND NOT B".
What are their truth tables?

A | B | NOT A | NOT B | NOT A AND B | NOT A AND NOT B
------+-----+-------+-------+-------------+-----------------
1: true |true | false | false | false | false
2: true |false| false | true | false | false
3: false|true | true | false | true | false
4: false|false| true | true | false | true

Remeber that the truth table for AND has true only when both
operands are true. For NOT A AND B, that happens when both the
NOT A and the B columns are true, which is row 3. For NOT A AND
NOT B, both NOT A and NOT B are true in row 4.

Since the two expressions have different truth tables, they are
not the same.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:

<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.'

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.683 / Virus Database: 445 - Release Date: 5/12/04
Jul 23 '05 #6
"Charles Crume" <cc@charlescrumesoftware.com> writes:
But in some computer languages these two statements are NOT the same because
the NOT operator sometimes takes precedence over the AND operator (it's one
level up in the hierarchy) and NOT A AND B is processed as (NOT A) AND B.
That is how I read it. Unary operators typically have much higher
precedence than binary operators, so NOT A AND B would be read as
(NOT A) AND B (and that is how Javascript does it too).
However, being fairly new to javascript, I can't seem to find any precedence
guidelines in the books I currently have.
You can derive the precendence from the grammar of the ECMAScript standard,
but for now, just remember that unary beats binary (and AND beats OR if it
matters). If I'm not mistaken, the precedence of operators in Javascript
is the same as in Java.
I wrote the attached HTML file which shows (unless I made a mistake
in my javascript coding) that these two statements *are not* the
same.


I see no attachment (give a link to a page anyway, it's easier to
use). If you used an actual "attachment" (as in MIME encoded), then
it was probably stripped by your news service provider, since this is
not a binary group.

Good luck
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #7
Hi Lasse;

[snip]
You can derive the precendence from the grammar of the ECMAScript standard
OK, I will check this out when I have some free time.

I see no attachment (give a link to a page anyway, it's easier to
use).


Attachment in follow up post. Do you see it? (I'll remember to upload to my
site and use a link in the future.)

Charles...
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.683 / Virus Database: 445 - Release Date: 5/12/04
Jul 23 '05 #8
JRS: In article <Nx****************@fe2.columbus.rr.com>, seen in
news:comp.lang.javascript, Charles Crume <cc@charlescrumesoftware.com>
posted at Thu, 13 May 2004 21:13:17 :

However, being fairly new to javascript, I can't seem to find any precedence
guidelines in the books I currently have.


They are on mostly Page 10 of the first edition of David Flanagan:
JavaScript Pocket Reference, 2nd Edition. ISBN 0-596-00411-7.

So they are probably in the second edition, and in the Definitive Guide;
see FAQ, 3.1.

<URL:http://www.merlyn.demon.co.uk/js-logic.htm> may be of interest; it
includes the de Morgan equivalences.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #9

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

Similar topics

3
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old...
1
by: the_proud_family | last post by:
HELP ME PLEASE!! my email is the_proud_family@yahoo.com I can't get the ball to go up right side and then I need it to turn around and keep turning until velocity=0 I have been at it for the ...
0
by: Kurt Watson | last post by:
I’m having a different kind of problem with Hotmail when I sign in it says, "Web Browser Software Limitations Your Current Software Will Limit Your Ability to Use Hotmail You are using a web...
12
by: Christo | last post by:
borland c++ 5.01 character constant must be one or two characters long get this when compiling my first c++ program can anyone out there help? it is highlighting this line as the problem ...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
17
by: JT | last post by:
Help me the following C++ question: Write a program to help a local bookshop automate its billing system. The program should do the following: (a)Let the user enter the ISBN, the system will...
7
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
2
by: =?Utf-8?B?U2NvdHRSYWREZXY=?= | last post by:
I'm creating a doc project for my c# program. I've done this before but this time sonething is wrong. I build my doc project and is succeeds but when I open the help file, there is no documentation...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.