Connecting Tech Pros Worldwide Forums | Help | Site Map

HELP please

Cyberdog
Guest
 
Posts: n/a
#1: Jul 23 '05
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
Guest
 
Posts: n/a
#2: Jul 23 '05

re: HELP please


Cyberdog <david.midcom@INVALID.com> writes:
[color=blue]
> 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".[/color]

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 - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Cyberdog
Guest
 
Posts: n/a
#3: Jul 23 '05

re: HELP please


On Thu, 13 May 2004 20:13:10 +0200, Lasse Reichstein Nielsen
<lrn@hotpop.com> wrote:
[color=blue]
>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.[/color]
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.
Evertjan.
Guest
 
Posts: n/a
#4: Jul 23 '05

re: HELP please


Cyberdog wrote on 13 mei 2004 in comp.lang.javascript:
[color=blue]
> 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[/color]

[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)
Lasse Reichstein Nielsen
Guest
 
Posts: n/a
#5: Jul 23 '05

re: HELP please


Cyberdog <david.midcom@INVALID.com> writes:
[color=blue]
> Thanks for that, It would seem that "NOT ( A AND B)" is actually
> equivalent to "(NOT A OR NOT B)"[/color]

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 - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Charles Crume
Guest
 
Posts: n/a
#6: Jul 23 '05

re: HELP please


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" <david.midcom@INVALID.com> wrote in message
news:jie7a0liu8e0vg4r70fftqofnhukqepes1@4ax.com...[color=blue]
> 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[/color]



"Lasse Reichstein Nielsen" <lrn@hotpop.com> wrote in message
news:1xloci15.fsf@hotpop.com...[color=blue]
> Cyberdog <david.midcom@INVALID.com> writes:
>[color=green]
> > 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".[/color]
>
> 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 - lrn@hotpop.com
> DHTML Death Colors:[/color]
<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>[color=blue]
> 'Faith without judgement merely degrades the spirit divine.'[/color]


---
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


Lasse Reichstein Nielsen
Guest
 
Posts: n/a
#7: Jul 23 '05

re: HELP please


"Charles Crume" <cc@charlescrumesoftware.com> writes:
[color=blue]
> 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.[/color]

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).
[color=blue]
> However, being fairly new to javascript, I can't seem to find any precedence
> guidelines in the books I currently have.[/color]

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.
[color=blue]
> 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.[/color]

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 - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Charles Crume
Guest
 
Posts: n/a
#8: Jul 23 '05

re: HELP please


Hi Lasse;

[snip]
[color=blue]
> You can derive the precendence from the grammar of the ECMAScript standard[/color]

OK, I will check this out when I have some free time.

[color=blue]
> I see no attachment (give a link to a page anyway, it's easier to
> use).[/color]

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


Dr John Stockton
Guest
 
Posts: n/a
#9: Jul 23 '05

re: HELP please


JRS: In article <NxRoc.8762$sA.7798@fe2.columbus.rr.com>, seen in
news:comp.lang.javascript, Charles Crume <cc@charlescrumesoftware.com>
posted at Thu, 13 May 2004 21:13:17 :[color=blue]
>
>However, being fairly new to javascript, I can't seem to find any precedence
>guidelines in the books I currently have.[/color]

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.
Closed Thread