469,641 Members | 1,184 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,641 developers. It's quick & easy.

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 1080
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by the_proud_family | last post: by
12 posts views Thread by Christo | last post: by
5 posts views Thread by Craig Keightley | last post: by
17 posts views Thread by JT | last post: by
7 posts views Thread by tyler_durden | last post: by
23 posts views Thread by Jason | last post: by
2 posts views Thread by =?Utf-8?B?U2NvdHRSYWREZXY=?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.