13

Bitwise operations are mathematical in nature but are largely relevant in programming. I have a question pertaining to bitwise operators but am not sure which site to post it on.

My question: How can I determine what values of edx make energy equal to eax in the equation energy = (eax XOR 0x01010101) XOR edx where eax = (edx XOR energy) XOR 0x01010101? Plugging in random numbers and checking results is unfavorable. I need a clear cut solution. All variables are 4 byte unsigned integers represented in hex.

8
  • Is the question specific to an implementation or theory?
    – Stephen Rauch Mod
    May 13, 2018 at 3:24
  • 1
    Post a snippet of your question here and we can tell you if it's suitable or not. Just be braced for constructive criticism.
    – Makoto
    May 13, 2018 at 3:40
  • 1
    @Makoto Will do. May 13, 2018 at 4:05
  • Answered my own question anyways. You can only XOR 0x01010101 with a certain value to get eax. Just like if y = 4 in x + 3 = y then x will always be 1. May 13, 2018 at 4:31
  • 1
    This particular example is unclear on whether you'd have needed to figure out how to work out the solution for specific eax values, or programmatically for arbitrary eax values. These potentially would have required very different types of answers, so it's entirely possible that the best site to post it on is different for the two cases. Can you edit your question to make it clearer which one you're interested in?
    – user743382
    May 13, 2018 at 7:16
  • re. the question itself: you can see that as there are no carrying operations, you can simply solve it for individual bits (all bits are mutually independent). and then there are only so much possible variants. May 13, 2018 at 11:42
  • Math.SE seems okay, but Computer Science SE should be fine too.
    – adjan
    May 13, 2018 at 11:56
  • @EdwardSeverinsen Off-topic: "You can only XOR 0x01010101 with a certain value to get eax" -- Not really. Note that, in your analogy, there is exactly one solution because f(x) = x + 3 is a bijection.
    – duplode
    May 13, 2018 at 14:10

2 Answers 2

2

As Adrian points out:

Math.SE seems okay, but Computer Science SE should be fine too.

The [boolean-algebra] tag at Math.SE would be a suitable destination, according to my understanding of this question on their Meta (your question would fall under "'algebra of logic', i.e. basic calculus with truth values"). The evidence is less clear-cut when it comes to CS.SE, but a quick look at their own [boolean-algebra] tag suggests it would be fine to post it there as well. If I were to recommend just one site, I'd say Math.SE.

1
  • Chose this answer because it included a definite answer for where it does belong. May 14, 2018 at 2:07
1

Title: Do bitwise/logical operator math questions belong on Stack Overflow or Math.StackExchange?

I think the title answers it self, i.e. the part math questions tells you that Stack Overflow isn't the correct site.

After reading the question body, it still seems to me that the question is more math related than programming related. So once again I will say that Stack Overflow isn't the correct site.

You can ask questions about bitwise/logical operators on Stack Overflow but the context must be programming. Solving an equation isn't.

My conclusion: The question seems to be off-topic for Stack Overflow.

Whether the question is on-topic for Math.StackExchange I can't tell.

2
  • 1
    Solving equations with code tho is totally on-topic. May 14, 2018 at 16:00
  • 1
    @KennyEvitt Agree - That would make the context programming and therefore on-topic. However, there seems to be no such thing in OP's question. May 14, 2018 at 16:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .