Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: nitacku on September 02, 2010, 11:20:36 pm
-
I'm a bit confused about the results of this code:
:.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?
-
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)
-
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.
-
...
If X≠0 and (Y≠0)
...
and
...
!If X or Y
...
produce different results. The first gives all "YES" and the second gives all "NO."
-
You're right, meishe. I forgot what he wanted the statement to do.
-
Ah ok, gotcha.
-
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...
-
That might be a really useful thing to note :O
-
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.
-
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
-
Here it is: http://ourl.ca/4072/111167 (http://ourl.ca/4072/111167)
-
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.