Author Topic: Axe Boolean Logic  (Read 5147 times)

0 Members and 1 Guest are viewing this topic.

Offline nitacku

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 300
  • Rating: +30/-1
  • ni-ta-ku ^_^
    • View Profile
Axe Boolean Logic
« 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?

_player1537

  • Guest
Re: Axe Boolean Logic
« Reply #1 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)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Boolean Logic
« Reply #2 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.
« Last Edit: September 02, 2010, 11:52:35 pm by Runer112 »

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Axe Boolean Logic
« Reply #3 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."
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Boolean Logic
« Reply #4 on: September 02, 2010, 11:53:02 pm »
You're right, meishe. I forgot what he wanted the statement to do.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Axe Boolean Logic
« Reply #5 on: September 02, 2010, 11:56:18 pm »
Ah ok, gotcha.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: Axe Boolean Logic
« Reply #6 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...
« Last Edit: September 03, 2010, 01:44:45 am by LordConiupiter »
everytime that I was down, you would always come around, and get my feedback on the ground. (modified part from 'Seasons in the sun')

No matter how many errors are bothering you, always try to stay rel-Axe!

The HoMM project will be resumed as soon Axe 1.0.0 will be released!
Projects:
Code: [Select]
HoMM:   [==--------]    Project 'resumed': I'm suffering overwhelming new ideas being popped up in my dreams :P
tiDE:   [----------]    Explored and understood the main part of the code: just started writing a Tokenizer.



password of the week: uvanapererubupa (Any pronunciation is the right one ;) )   :D click me, and you'll be raided :D

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Boolean Logic
« Reply #7 on: September 03, 2010, 01:42:15 am »
That might be a really useful thing to note :O

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Boolean Logic
« Reply #8 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.




Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: Axe Boolean Logic
« Reply #9 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
everytime that I was down, you would always come around, and get my feedback on the ground. (modified part from 'Seasons in the sun')

No matter how many errors are bothering you, always try to stay rel-Axe!

The HoMM project will be resumed as soon Axe 1.0.0 will be released!
Projects:
Code: [Select]
HoMM:   [==--------]    Project 'resumed': I'm suffering overwhelming new ideas being popped up in my dreams :P
tiDE:   [----------]    Explored and understood the main part of the code: just started writing a Tokenizer.



password of the week: uvanapererubupa (Any pronunciation is the right one ;) )   :D click me, and you'll be raided :D

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Boolean Logic
« Reply #10 on: September 03, 2010, 04:50:25 pm »




Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Axe Boolean Logic
« Reply #11 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.
___Axe_Parser___
Today the calculator, tomorrow the world!