Bit wise operators

Bit wise operators and % operator cannot be applied to float
fmod() is to find modulus for float as % is for int
but it needs math.h;
This can be used to detect whether a given number is an integer or a float value;
fmod(Var,1.0)==0 ? printf(“Yes it is integer”) : printf(“Not an integer”);

Bit fields
Bit fields can be used ( inside an struct) to specify the number of bits that should be used as per the requirement.
C lets us do this in a structure definition by putting :bit length after the variable. i.e.
struct packed_struct {
unsigned int f1:1;
unsigned int f2:1;
unsigned int f3:1;
unsigned int f4:1;
unsigned int type:4;
unsigned int funny_int:9;
} pack;

One thought on “Bit wise operators

  1. I read this post fully on the topic of the difference of latest and preceding
    technologies, it’s awesome article.

Leave a Reply

Your email address will not be published. Required fields are marked *