V
Vijay Kumar R Zanvar
Hi,
Just like counting the number of bits set to
1 in an integral variable, can we count the same
in a float?
I have two solutions in my mind:
1.
union {
float f;
int i;
}u = { 10 };
Now, count the required number from u.i.
Will this work?
2.
float f;
unsigned char uc[sizeof (float)];
memcpy ( uc, &f, sizeof (float) );
Now count from the array. How about this?
Season's Greetings!
Just like counting the number of bits set to
1 in an integral variable, can we count the same
in a float?
I have two solutions in my mind:
1.
union {
float f;
int i;
}u = { 10 };
Now, count the required number from u.i.
Will this work?
2.
float f;
unsigned char uc[sizeof (float)];
memcpy ( uc, &f, sizeof (float) );
Now count from the array. How about this?
Season's Greetings!