# Re: [Warzone-dev] x >> TILE_SHIFT vs. x / TILE_UNITS

```Am Mittwoch, 14. März 2007 schrieb Per Inge Mathisen:
> On 3/14/07, Per Inge Mathisen <[EMAIL PROTECTED]> wrote:
> > These are not bitshifts instead of multiplication or division by a
> > power of two, but actually bitshifts to conserve the precious memory
> > of the PSX. The correct solution is to expand the relevant structures
> > a bit, so that we do not have to compress the data by bitshifting.
> > I've wanted to do this for a long time, but I never got around to it.
>
> Actually, I was thinking of something else when I wrote this. I
> realized this when I saw your commit.
>
> Although you could just store both world and tile coordinates and
> avoid the bitshifts, they are of course actually used for
> multiplication and division in this case.
I read about something like that in Gems4, maybe it is what you mean:
Store the tile coordinate and a more precise coordinate as an offset into that
tile. Chapter 2.4, ~~Precisionproblems of large world coordinates~~```
```
So you would get something like this (copied from the above mentioned book):
struct droid{
Vector2s tileCoord;
Vector3f offsetCoord;
...
};

Vector3f getWorldCoord(tileCoord, offsetCoord)
{
return tileCoord * tileSize + offsetCoord;
}

union Vector2s{
struct {
Uint16 x, y;
};
Uint32 xy;
};
(He made it a union for easier initialization and comparison. Mostly added it
here, because I didn't know about anonymous structs before. Possibly handy in
some situations.)

> Now, the other TILE_* macros and definitions, on the other hand,
> really could really use larger structs instead of compressing lots of
> data by bitshifting.
You mean stuff like this?
#define TILE_OCCUPIED(x)                (x->tileInfoBits & BITS_OCCUPIED)
#define TILE_HAS_STRUCTURE(x)   (x->tileInfoBits & BITS_STRUCTURE)
#define TILE_HAS_FEATURE(x)             (x->tileInfoBits & BITS_FEATURE)

Even though it is not extremely ugly, it could be done using a bitset, I
agree. I guess it wouldn't even harm performance or memory size.

-Dennis
```

```_______________________________________________