Wednesday, December 21, 2011
Variable memory size
While doing complexity theory assignment of 'assignment problem',
I learn that a good program should use as less memory allocation as possible.
Following list is the range of numbers on these defined variables,
(1) unsigned char : 0 through 255
(2) unsigned short : 0 through 65 535
(3) unsigned int : 0 through 65 535
(4) unsigned long : 0 through 4 294 967 295
(1) signed char: -127 through 127
(2) signed short: -32 767 through 32 767
(3) signed int: -32 767 through 32 767
(4) signed long: -2 147 483 647 through 2 147 483 647
The list shows that unsigned char is the smallest size of variable can be assign to a number,
Meanwhile signed long variable is large size and consume most memory allocation for a number.
Subscribe to:
Posts (Atom)