F
Frederick Gotham
Martijn van Buul posted:
Show me where a char is faster than an int.
Furthermore, given that a char is slower than an int, show me why you would
want to use one for storing an integer (or than creating massive arrays).
"char" doesn't have alignment requirements.
Don't a lot of Intel chips work like that? 486? Pentium?
Yes indeed, it would be quicker.
Three bytes is a drop in the ocean.
It proves that the char's haven't been placed directly after each other in
memory. Guess why.
Perform arithmetic or equality on it and see what happens.
My stance is this: Never use char unless memory is scarce.
Utter nonsense. There are plenty of reasons and plenty of applications
where you *do* want to use a char if possible, and where it would even
be *faster*.
Show me where a char is faster than an int.
Furthermore, given that a char is slower than an int, show me why you would
want to use one for storing an integer (or than creating massive arrays).
*most* systems? Nonsense. Only on systems with a severe alignment
problem.
"char" doesn't have alignment requirements.
1) Those systems, should they exist, are rare.
Don't a lot of Intel chips work like that? 486? Pentium?
2) It would only be "efficient" from a minimum-execution-time point of
view.
Yes indeed, it would be quicker.
It's grossly inefficient regarding memory usage.
Three bytes is a drop in the ocean.
An easy test for this is the following:
#include <stdio.h>
int main(void)
{
struct FourBytes { char a,b,c,d; };
switch(sizeof(struct FourBytes))
{
case sizeof(char[4]):
puts("Packed nice and tight!");
break;
This "proves" nor disproves absolutely nothing.
It proves that the char's haven't been placed directly after each other in
memory. Guess why.
Nonsense. Again.
Perform arithmetic or equality on it and see what happens.
My stance is this: Never use char unless memory is scarce.