How to convert IP to hex using C++

Pages: 12
That style:
- uses more memory
- introduces locking heap in the heap
- is not exception safe
- is slower
Is there an advantage to

1
2
3
4
5
6
7
struct PIXEL 
{
	unsigned int A:8;
	unsigned int R:8;
	unsigned int G:8;
	unsigned int B:8;
};

over

1
2
3
4
5
6
7
struct PIXEL 
{
	unsigned char A;
	unsigned char R;
	unsigned char G;
	unsigned char B;
};

?

Andy
In this case both structures allocated the same amount of memory (4 bytes) ,however, when you perform mathematical calculations the structure of int should offer better performance than the structure of chars especially if the CPU that will make these calculations is 32-bit architecture.
Topic archived. No new replies allowed.
Pages: 12