Jef! Posted November 2, 2018 Posted November 2, 2018 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! Quote
Lee Mac Posted November 2, 2018 Posted November 2, 2018 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 1 1 Quote
Jef! Posted November 3, 2018 Author Posted November 3, 2018 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?) Quote
Recommended Posts
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.