|
2 registered members (TipmyPip, USER0328),
8,405
guests, and 0
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Super-small var-type?
#308284
02/02/10 18:33
02/02/10 18:33
|
Joined: Oct 2007
Posts: 306 Austria
Alan
OP
Senior Member
|
OP
Senior Member
Joined: Oct 2007
Posts: 306
Austria
|
Hi there,
I'm currently working on a new project where I have to use a binary tree which may become rather big. Therefore I need to keep the nodes themselves as small in size as possible. Quite frequently I have integer values which range only from 0 to 255, so they could be saved in 1 Byte. In original C, there is the "byte" type for that. However, it seems not to exist in lite-C according to the manual. Can I define a data-type which stores an integer value between 0 and 255 in 1 Byte of memory? If so, how do I do that?
EDIT: How about True/False-Values? Boolean values take only 1 bit to save. It would be a real waste to use even a "short" integer for that. Is there any more "economic way" to do this?
Thanks in advance,
Alan
Last edited by Alan; 02/02/10 18:36.
|
|
|
Re: Super-small var-type?
[Re: Alan]
#308285
02/02/10 18:35
02/02/10 18:35
|
Joined: May 2007
Posts: 2,043 Germany
Lukas
 
Programmer
|
 
Programmer
Joined: May 2007
Posts: 2,043
Germany
|
|
|
|
Re: Super-small var-type?
[Re: Lukas]
#308288
02/02/10 18:40
02/02/10 18:40
|
Joined: Oct 2007
Posts: 306 Austria
Alan
OP
Senior Member
|
OP
Senior Member
Joined: Oct 2007
Posts: 306
Austria
|
So I won't get any trouble because of type conversion if I write something like:
char a_var;
a_var = 180;
In some languages this DOES cause some serious trouble.
EDIT: And how about boolean values? Any chance to use only 1 Bit for them?
Last edited by Alan; 02/02/10 18:43.
|
|
|
|