I am repeatedly sending data over UDP socket. Data is of format.
int bid
int ask
int price
All fields are conditional. so, I am using 3 additional bits to track which fields are present in the message. And I am writing these fields to char array before sending.
So my format becomes.
[ first 3 bits | 5 bits] [ ? 32 ] [ ? 32 ] [ ? 32 ]
Problem is that I am wasting 5 bits. I can do dirty pointer airthmetic with binary operations to save those bits but it may be taking away the processing speed. How can I do it cleanly and efficiently in c++ ?
Please provide a simple code snippet for this.
Aucun commentaire:
Enregistrer un commentaire