Assuming an int
in C++ is represented by 4 bytes, and an unsigned char
is represented by 1 byte, you could represent an int
with an array of unsigned char
with 4 elements right?
My question is, are there any performance downsides to representing a number with an array of unsigned char
? Like if you wanted to add two numbers together would it be just as fast to do int + int
compared to adding each element in the array and dealing with carries manually?
This is just me trying to experiment and to practice working with bytes rather than some practical application.