B
Bartholomew Simpson
I need to pack two small values into a double data type.
I have come up with the following struct, which only takes up 16 bits
and can therefore be stored safely in a double.
struct mytype_
{
unsigned char fld1: 4,
fld2: 12;
};
My question though is how do I assign a value of type mytype to a double
(and back from a double)?
struct mytype_ snoopy ;
double foobar ;
snoopy.fld1 = 2;
snoopy.fld2 = 256 ;
//Are these legal (i.e. will they behave as expected - display value
semantics behaviour)?
foobar = snoopy ;
snoopy = foobar ;
I have come up with the following struct, which only takes up 16 bits
and can therefore be stored safely in a double.
struct mytype_
{
unsigned char fld1: 4,
fld2: 12;
};
My question though is how do I assign a value of type mytype to a double
(and back from a double)?
struct mytype_ snoopy ;
double foobar ;
snoopy.fld1 = 2;
snoopy.fld2 = 256 ;
//Are these legal (i.e. will they behave as expected - display value
semantics behaviour)?
foobar = snoopy ;
snoopy = foobar ;