Hello all, I am using bitfields to get easy access on a float library I am trying to make for a microcontroller with no FPU.
The problem is that I can't seem to make it work with bitfields. Take a look:
typedef struct
{
union{
unsigned long mantissa: 23;
unsigned long exponent: 8;
unsigned long sign: 1;
float all;
};
}_float __attribute__((__packed__));
The problem is that when I try to access or change anything it considers the bitfields as 1,8,23 bits from the end respectively. While it should be 23 bits from the end, then 8 bits and then the last bit. Unless I have totally misunderstood the use of bitfields. I thought that using packed would solve the problem but as you can see it didn't.
Any help would be really appreciated. I have been lead to this site while googling more than once so I have high hopes.