Jump to content

Recommended Posts

Posted

image.png.cad1f82d6c6ab99cb111ca7359cdda0c.png

Exclusive NOR the output should be 1 if both inputs are the same, 0/0 (operator bit 8 ) + 1/1 (operator bit 1). So operator bit 9.

(boole 9 0 0) and (boole 9 1 1) should return 1, while (boole 9 0 1) and (boole 9 1 0) should return 0

I just tested in Cad 2013/2014/2015 and 2016 and...

(boole 9 0 0) and (boole 9 1 1) return -1 while (boole 9 0 1) and (boole 9 1 0) return -2. (!)

 

I worked around that bug using "not XOR", ie: (- 1 (boole 6 0 0)), but I would still be curious if other and/or newer versions of Autocad than the above-mentioned (2012- / 2017+) had/still have that (boole 9 bug. I would also be curious to know if BricsCad have the same bug. What cad software do you use, what version and what does (boole 9 return?

 

Thanks and have a great week end!

Posted

This is not a bug. Signed integers are stored in 32-bit 2's complement representation and so we have the following when performing the bitwise operations:

(boole 9 0 1) =

0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 =  0
0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 1 =  1
----------------------------------------------------------------------- NOT XOR
1 1 1 1 1 1 1 1  1 1 1 1 1 1 1 1  1 1 1 1 1 1 1 1  1 1 1 1 1 1 1 0 = -2

 

  • Like 1
  • Thanks 1
Posted
36 minutes ago, Lee Mac said:

This is not a bug. Signed integers are stored in 32-bit 2's complement representation and so we have the following when performing the bitwise operations:


(boole 9 0 1) =

0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 =  0
0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 1 =  1
----------------------------------------------------------------------- NOT XOR
1 1 1 1 1 1 1 1  1 1 1 1 1 1 1 1  1 1 1 1 1 1 1 1  1 1 1 1 1 1 1 0 = -2

 

Oh! Right. Each bit of int1 is paired with the corresponding bit of int2. I was checking with 2 input logic gate literature. My bad.

As long as I'm comparing only 1's and 0's, (- 1 (boole 6 0 0)) does what I need but a more robust solution to get 1 if and only if both int inputs bit x are the same would be as follow

(boole 1 x (boole 9 int1 int2))

 

(boole 1 1 (boole 9 0 0)) & (boole 1 1 (boole 9 1 1)) return 1

(boole 1 1 (boole 9 0 1)) & (boole 1 1 (boole 9 1 0)) return 0

 

Does it make sense? (or maybe I should ask is there anything that would make more sense?)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...