Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: nitacku on September 02, 2010, 11:20:36 pm

Title: Axe Boolean Logic
Post by: nitacku on September 02, 2010, 11:20:36 pm
I'm a bit confused about the results of this code:

Quote
:.AATEST
:ClrHome
:4→X
:For(Y,1,255)
:If X and Y
:Disp "Yes",Y►Dec,i
:Else
:Disp "No",Y►Dec,i
:End
:End

Instead of getting all "Yes", I get groups of "Yes" followed by groups of "No".
The size of the groups are equal to X.

Since this is just 8 bit logic, shouldn't this work?
Title: Re: Axe Boolean Logic
Post by: _player1537 on September 02, 2010, 11:29:22 pm
Just about.  This takes the values of the numbers and applies And logic.

Example:
1010 And 0110 = 0010

to do what you want:
If X != 0 and (Y != 0)
Title: Re: Axe Boolean Logic
Post by: Runer112 on September 02, 2010, 11:30:32 pm
The " and" token performs an 8-bit bitwise boolean AND. It ANDs every bit in X with the corresponding bits in Y. If none of the bit pairs are both 1s in X and Y, the resultant bits will all be 0 and the statement will be false. Seeing as only the 22 bit is set in 4, only numbers that have this bit set also will return true.

EDIT: Ninja'd, but I like my explanation better ;D

to do what you want:
If X != 0 and (Y != 0)

A more efficient operation:
!If X or Y


EDIT 2: JK, that's completely incorrect. I forgot what he was trying to achieve.
Title: Re: Axe Boolean Logic
Post by: meishe91 on September 02, 2010, 11:41:53 pm
Code: [Select]
...
If X≠0 and (Y≠0)
...

and

Code: [Select]
...
!If X or Y
...

produce different results. The first gives all "YES" and the second gives all "NO."
Title: Re: Axe Boolean Logic
Post by: Runer112 on September 02, 2010, 11:53:02 pm
You're right, meishe. I forgot what he wanted the statement to do.
Title: Re: Axe Boolean Logic
Post by: meishe91 on September 02, 2010, 11:56:18 pm
Ah ok, gotcha.
Title: Re: Axe Boolean Logic
Post by: LordConiupiter on September 03, 2010, 01:40:58 am
Axe boolean checks only the last bit of the byte pointed to I found out. to you get Yes only for odd numbers, and No for the even numbers :P
so b10101 And b0110 will be 0 And 0 for Axe, and b0101 And b0110 will be 1 and 0 for . so both numbers have to be odd.

Bool is just only the last bit of a byte!


correct me if I'm wrong, but this is what I thought based on my experiences with trying Bool-using statements as they all are...
Title: Re: Axe Boolean Logic
Post by: Builderboy on September 03, 2010, 01:42:15 am
That might be a really useful thing to note :O
Title: Re: Axe Boolean Logic
Post by: Deep Toaster on September 03, 2010, 04:36:36 pm
I think I read somewhere that it takes one nibble from the first value and the opposite nibble from the second, though...

Axe boolean checks only the last bit of the byte pointed to I found out. to you get Yes only for odd numbers, and No for the even numbers :P
so b10101 And b0110 will be 0 And 0 for Axe, and b0101 And b0110 will be 1 and 0 for . so both numbers have to be odd.

Bool is just only the last bit of a byte!


correct me if I'm wrong, but this is what I thought based on my experiences with trying Bool-using statements as they all are...

I don't exactly get that...

It seems if that were true, 2 and 3 would return false, but it's true.
Title: Re: Axe Boolean Logic
Post by: LordConiupiter on September 03, 2010, 04:48:38 pm
well, it was a theory, but it's proved to be wrong I see. let's think of a new theory. Or should we perhaps just ask Quigibo? :P
Title: Re: Axe Boolean Logic
Post by: Deep Toaster on September 03, 2010, 04:50:25 pm
Here it is: http://ourl.ca/4072/111167 (http://ourl.ca/4072/111167)
Title: Re: Axe Boolean Logic
Post by: Quigibo on September 03, 2010, 11:16:15 pm
Yes, "and" "or" and "xor" all operate exclusively on the low byte (8 bits).  You have to use the plot style tokens to do bit logic on 16 bit numbers.  I am thinking it could eventually be possible to have C style Boolean logic in Axe++ which would be the 2.0 version but I don't know if that would ever get completed, I have to worry about 1.0 for now and still have a long way to go.