|
Simplify (x & ~y) > (~x & y)
I quite liked how it just works out, and it's a nice little puzzle assuming you haven't seen it before, not so hard that it'll cost you your weekend, but good enough to tease your brain for a couple of minutes.
The comparison can be taken as signed or unsigned.
ps: I actually needed this thing today, but the other way around. I had to compute what this thing simplifies to, but only had x & ~y and ~x & y available.
|
|
|
|
|
This[^] Becomes This[^]
Assuming the x and y are Chromosomes
---------------------------------
Obscurum per obscurius.
Ad astra per alas porci.
Quidquid latine dictum sit, altum videtur .
|
|
|
|
|
Yes. Full points awarded.
|
|
|
|
|
Let x = 10, y = 20
Then
~y = -21
~x = -11
(x & ~y) = 10 & -21
(~x & y) = -11 & 20
Then perform bitwise operation , Refer - Bit wise operations in C#[^]
Thanks,
|
|
|
|
|
Ok, but that's not a simplification.
|
|
|
|
|
True. Unfortunately you are shifting every bit of my brain nerves ![Laugh | :laugh:](https://www.codeproject.com/script/Forums/Images/smiley_laugh.gif)
|
|
|
|
|
You could try picking values for x and y until you see a pattern..
Do you want a hint?
|
|
|
|
|
You should have specified the field here. Mathematical ~ means a bit different. Where's the not impressed icon?
"Bastards encourage idiots to use Oracle Forms, Web Forms, Access and a number of other dinky web publishing tolls.", Mycroft Holmes[ ^]
|
|
|
|
|
Since it doesn't make sense if interpreted that way, it's not really ambiguous.
|
|
|
|
|
Yes, it does not make any sense when looked that way. It also may not make any sense in a rare programming language that treats ~ as declaration symbol and & as = symbol. It would be a really stupid language BTW.
Like you guys say, just my 2 cents.
"Bastards encourage idiots to use Oracle Forms, Web Forms, Access and a number of other dinky web publishing tolls.", Mycroft Holmes[ ^]
|
|
|
|
|
It could be simplified to x > y
How this works:
Let's take two random numbers for x and y :
x = 37 = 00100101
y = 203 = 11001011
The values for ~x and ~y :
~x = 11011010
~y = 00110100
And the values for (x & ~y) and (~x & y)
x & ~y = 00100101 & 00110100 = 00100100 = 36
~x & y = 11011010 & 11001011 = 11001010 = 202
In this case, x and y are both substracted with 1 . That's not always the case, but if you try this with other numbers, you'll see that x and y are always substracted with the same number.
modified 24-Jan-14 13:56pm.
|
|
|
|
|
Take a +5.
Out of curiosity, how did you do it? Or did you already know?
|
|
|
|
|
harold aptroot wrote: how did you do it?
I updated my message to add some explanation.
|
|
|
|
|
ProgramFOX wrote: That's not always the case, but if you try this with other numbers, you'll see that x and y are always substracted with the same number. Ok, now it works (I caught your post just between edits).
Fun fact: that number is exactly x & y , and the general proof is
(x & ~y) > (~x & y)
// rewrite the & to a subtraction
(x - (x & y)) > (y - (y & x))
// subtracting the same thing on both sides doesn't change the order
x > y
|
|
|
|
|
harold aptroot wrote: Fun fact: that number is exactly x & y , and the general proof is
(x & ~y) > (~x & y)
// rewrite the & to a subtraction
(x - (x & y)) > (y - (y & x))
// subtracting the same thing on both sides doesn't change the order
x > y
+5! Nice general proof!
|
|
|
|
|
Imagine, if you will, a small, very dense star of a type known as a white dwarf. Imagine this star orbiting a much larger companion star, syphoning off its companion's gas and claiming it as its own. Imagine the dwarf gaining so much new mass that it reignites its thermonuclear furnace[^], blowing up in an explosion so bright that it will, briefly, outshine the whole galaxy. Imagine this light traveling for millions of years, until it reaches a tiny speck orbiting an ordinary star in the backwaters of another galaxy.
Or, you can just see it[^].
(Edit: renamed, so as not to be confused with an earlier post on a different topic.)
|
|
|
|
|
Yeah, its good picture but that little bright star is already gone, and you start thinking would it be someone to see when our "little" star explodes and photograph it.
Microsoft ... the only place where VARIANT_TRUE != true
|
|
|
|
|
Yeah, our little star isn't going to explode. Not enough mass.
It'll just become a red giant for a bit before it puffs off layer after layer of material. All fusion will eventually stop and it'll become a white dwarf....in about 4 billion years.
|
|
|
|
|
All that what we know about the stars are from watching the death and life of others. There is not one evidence that tomorrow our star wont become a black hole.
My point is maybe there is one cycle of the life/ death of a star which we didn't see yet and we just cant be sure what will happen and when, after all our lives are just a moment in a star's life. The only thing we know is it wont happen soon enough for us to see it :/ Too bad.
Microsoft ... the only place where VARIANT_TRUE != true
|
|
|
|
|
Argonia wrote: All that what we know about the stars are from watching the death and life of others.
I know that.
Argonia wrote: There is not one evidence that tomorrow our star wont become a black hole.
True. But it's impossible to prove a negative. The opposite of that would be that we haven't once seen a case where a star of ours mass has turned into a black hole.
The math, as we know astrophysics today, says that it's impossible for it to happen as our star only has about 60%(?) of the mass required to kick off a supernova. This minimum is known as the Chandrasekhar Limit[^].
...according to the math anyway.
|
|
|
|
|
I for one won't care either way what happens.
|
|
|
|
|
Dave Kreskowiak wrote: The math, as we know astrophysics today, says that it's impossible for it to happen as our star only has about 60%(?) of the mass required to kick off a supernova. This minimum is known as the Chandrasekhar Limit[^].
The Chandrasekhar limit is the cutoff point for a stellar remnant being able to remain a white dwarf instead of collapsing farther to a neutron star or black hole. As a solo star (there are processes that can detonate a white dwarf in a binary system - SN type Ia) the sun is at least 4 and almost certainly 8 times too small to supernova due to heavy mass loss during the red giant stage. Stellar evolution models require a minimum initial size of ~ 8 solar masses to trigger a conventional supernova. There's a theoretical, but never observed, supernova mode that could occur for stars of 4-8 solar masses in size; but the evolutionary models predict, and the lack of observations appear to confirm that any star in that initial mass range will shed enough mass via stellar wind during the red giant/super giant stages to end as a white dwarf.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
Awesome,I've followed a couple other posts and this is an extraordinary event.
|
|
|
|
|
what a disapointment I thought is was a new brew from stella artois
just kidding, wouldn't touch the stuff
You cant outrun the world, but there is no harm in getting a head start
Real stupidity beats artificial intelligence every time.
|
|
|
|
|
AKA 'punch up in a glass' would have though a man of breading would stay clear of that
Quote:
just kidding, wouldn't touch the stuff
Well that's a relief... back to video card heck!
|
|
|
|