Math in Unity : Grid and Bitwise operation (Part X)
We still have a little problem, which is this :
(with this line of code)

If we press Play we notice that the sphere is instantiated on the red and yellow tile, BUT

even above the sphere itself!
Now, there’s a chance we want exactly this kind of behavior in our game, and that would be fine.
But what if we only needed one object on the tile at a time?
Again, with our bitwise operators we can solve this problem!
If we chenage the code above into this

What happen?
I create a double check:
IF WE ARE ON REDTILE BUT THERE IS NO SPHERE

OR |
IF WE ARE ON YELLOWTILE BUT THERE IS NO SPHERE

run the code
If we make a test

Now we can only instantiate ONE SPHERE on the tiles of our choice.
NOTE : I was given great advice by a programmer with much more experience than me, which is this:
accessing the Transform (which is a component) many times, is exactly like writing this:
gameObject.GetComponent <Transform> ()
and doing it multiple times can cause overhead problems.
It is best to create a local variable and use it.
In this specific case, I have changed my code in this way

var sphereTransform = sphere.transform;
We can now access the transform directly via :
sphereTransform.parent
sphereTransform.localPosition
I hope this series on bits and bitwise operations will be useful to you.
As mentioned at the beginning, there are different ways to manage a grid and it always depends on the implementations you want to use, but using bits can still be an excellent alternative.