[Tutorial] An in-depth look at binary and binary operators.
#26

hey.. I put code too! : (
http://forum.sa-mp.com/showpost.php?...3&postcount=19

btw, to create arrays with unsigned 8bit integers, simply use the "char" keyword.


pawn Code:
new array[ 4 char ];

array{ 0 } = 10;
array{ 1 } = 20;
array{ 2 } = 30;
array{ 3 } = 40;

printf( "%d %d %d %d", array{ 0 }, array{ 1 }, array{ 2 }, array{ 3 } );
thanks Y_Less for reminding me about the curly brackets


Quote:
Originally Posted by Kyosaur
View Post
I'm not so sure about the second method though. Im all for saving memory, but i dont think the speed difference would be worth it for 4 unsigned 8 bit integers. That's just my view though, there's nothing wrong with it at all. To be honest, i never even thought about this once. Its pretty neat at the very least.
Say you have around 10 arrays size 500 that don't have values higher than 255 or lower than 0. Storing those in 4-byte cells would use a total of 20000 bytes, roughly 20kb. If you were using the arrays for packed strings, you would use only 5000 bytes (5 kb).

Also,
For arrays containing onle true/false, you could store those in each bit; resulting in 32 true/false values per cell. For a bit array size 500, would need only 16 cells! Comparing that to a normal array, you would save roughly 2kb for just one array!
Reply


Messages In This Thread
An in-depth look at binary and binary operators. - by Kyosaur - 18.09.2010, 10:50
Re: An in-depth look at binary and binary operators. - by Kyosaur - 18.09.2010, 10:52
Re: An in-depth look at binary and binary operators. - by LarzI - 18.09.2010, 11:07
Re: An in-depth look at binary and binary operators. - by Hiddos - 18.09.2010, 11:18
Re: An in-depth look at binary and binary operators. - by Leeroy. - 18.09.2010, 11:19
Re: An in-depth look at binary and binary operators. - by Kyosaur - 18.09.2010, 11:22
Re: An in-depth look at binary and binary operators. - by LarzI - 18.09.2010, 11:23
Re: An in-depth look at binary and binary operators. - by Mimic - 18.09.2010, 11:26
Re: An in-depth look at binary and binary operators. - by Hiddos - 18.09.2010, 11:27
Re: An in-depth look at binary and binary operators. - by Kyosaur - 18.09.2010, 11:34
Re: An in-depth look at binary and binary operators. - by DiddyBop - 18.09.2010, 12:53
Re: An in-depth look at binary and binary operators. - by Simon - 19.09.2010, 08:55
Re: An in-depth look at binary and binary operators. - by Kyosaur - 19.09.2010, 22:21
Re: An in-depth look at binary and binary operators. - by Backwardsman97 - 20.09.2010, 02:46
Re: An in-depth look at binary and binary operators. - by Hiddos - 23.09.2010, 16:09
Re: An in-depth look at binary and binary operators. - by Calgon - 23.09.2010, 19:35
Re: An in-depth look at binary and binary operators. - by Kyosaur - 23.09.2010, 22:34
Re: An in-depth look at binary and binary operators. - by Chaprnks - 24.09.2010, 00:45
Re: An in-depth look at binary and binary operators. - by Slice - 25.09.2010, 18:57
Re: An in-depth look at binary and binary operators. - by MrDeath537 - 26.09.2010, 00:04
Re: An in-depth look at binary and binary operators. - by LarzI - 26.09.2010, 09:56
Re: An in-depth look at binary and binary operators. - by Kyosaur - 26.09.2010, 10:16
Re: An in-depth look at binary and binary operators. - by Tannz0rz - 26.09.2010, 10:35
Re: An in-depth look at binary and binary operators. - by LarzI - 26.09.2010, 10:36
Re: An in-depth look at binary and binary operators. - by Kyosaur - 29.09.2010, 13:42
Re: An in-depth look at binary and binary operators. - by Slice - 29.09.2010, 14:24
Re: An in-depth look at binary and binary operators. - by Kyosaur - 29.09.2010, 14:55
Re: An in-depth look at binary and binary operators. - by Slice - 29.09.2010, 15:02
Re: An in-depth look at binary and binary operators. - by Kyosaur - 29.09.2010, 15:14
Re: An in-depth look at binary and binary operators. - by Slice - 29.09.2010, 15:41
Re: An in-depth look at binary and binary operators. - by LarzI - 29.09.2010, 16:35
Re: An in-depth look at binary and binary operators. - by Tannz0rz - 29.09.2010, 17:47
Re: An in-depth look at binary and binary operators. - by LarzI - 29.09.2010, 18:11
Re: An in-depth look at binary and binary operators. - by [HLF]Southclaw - 09.03.2011, 19:11
Re: An in-depth look at binary and binary operators. - by Kyosaur - 09.03.2011, 23:39
Re: An in-depth look at binary and binary operators. - by black_dota - 10.03.2011, 06:18
Re: An in-depth look at binary and binary operators. - by alpha500delta - 10.03.2011, 13:21
Re: An in-depth look at binary and binary operators. - by Kyosaur - 10.03.2011, 13:32
Re: An in-depth look at binary and binary operators. - by [HLF]Southclaw - 10.03.2011, 15:33
Re: An in-depth look at binary and binary operators. - by Mean - 10.03.2011, 16:02
Re: An in-depth look at binary and binary operators. - by SkizzoTrick - 10.03.2011, 17:20
Re: An in-depth look at binary and binary operators. - by Wesley221 - 03.10.2011, 17:08
Re: An in-depth look at binary and binary operators. - by Cank - 07.10.2011, 15:04
Re: An in-depth look at binary and binary operators. - by [MM]IKKE - 11.10.2011, 23:36
Re: An in-depth look at binary and binary operators. - by Kyosaur - 11.10.2011, 23:56
Re: An in-depth look at binary and binary operators. - by Davz*|*Criss - 12.10.2011, 10:58
Re: An in-depth look at binary and binary operators. - by [MM]IKKE - 12.10.2011, 11:33
Re: An in-depth look at binary and binary operators. - by Kyosaur - 13.10.2011, 03:58
Re: An in-depth look at binary and binary operators. - by [HLF]Southclaw - 13.10.2011, 10:44
Re: An in-depth look at binary and binary operators. - by System64 - 31.03.2012, 12:41
Re: An in-depth look at binary and binary operators. - by LarzI - 05.05.2013, 14:20
Re: An in-depth look at binary and binary operators. - by Pandex - 01.08.2013, 20:41

Forum Jump:


Users browsing this thread: 2 Guest(s)