P
Philipp
Hello,
I have a class Position which declares a bit field
class Position{
public:
Position(int i=0, int j=0, int k=0);
// Positions have to be within the range: [0..8191,0..8191,0..7]
void setPosition(int i, int j, int k);
int getI();
int getJ();
int getK();
friend ostream& operator<< (ostream& outs, const Position &rhs);
private:
unsigned short i:13;
unsigned short j:13;
unsigned short k:3;
};
How efficient is this technique to save memory (I have a lot of Position
objects)? What size of memory will the three vars i,j,k really occupy in
the memory?
Does this depend on the compiler (icc 7.1 on linux)? On the architecture
(i686)?
Thanks for answers
Phil
I have a class Position which declares a bit field
class Position{
public:
Position(int i=0, int j=0, int k=0);
// Positions have to be within the range: [0..8191,0..8191,0..7]
void setPosition(int i, int j, int k);
int getI();
int getJ();
int getK();
friend ostream& operator<< (ostream& outs, const Position &rhs);
private:
unsigned short i:13;
unsigned short j:13;
unsigned short k:3;
};
How efficient is this technique to save memory (I have a lot of Position
objects)? What size of memory will the three vars i,j,k really occupy in
the memory?
Does this depend on the compiler (icc 7.1 on linux)? On the architecture
(i686)?
Thanks for answers
Phil