123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|441|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> Bit byte thingamabob

Tue, 25 Jan 2011, 02:52
Afr0
Let's say I have an int (technically a long).
Let's say I need to store it as 3 bytes (which doesn't conform to a standard type).

How?

I'm using C#....

(It has the same bitwise operators as Blitz)

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Tue, 25 Jan 2011, 03:11
Jayenkai
Coding, brb...
Tue, 25 Jan 2011, 03:45
Jayenkai


Took longer than expected. Another PC at work's fried! lol!

-=-=-
''Load, Next List!''
Tue, 25 Jan 2011, 03:54
Afr0
Thanks!
Tue, 25 Jan 2011, 19:44
dna
Just to understand this more, when you mentioned that you were putting a long integer into three bytes, visually:

1) how long were you thinking at maximum.

2) how, does this store, let's say, a ten digit number into 3 bytes

3)how does the reverse work since I'm not clearly seeing them go into 3 bytes.

Thanks in advance.

-=-=-
DNA
Tue, 25 Jan 2011, 20:48
Jayenkai
You're thinking the wrong way around, DNA.
He already has a bunch of 3 bit numbers (0-7), and rather than use a 32 bit integer to store each one, he's going to cram a bunch of the 3 bit numbers into one long 32 bit number.

Imagine it like so..

You go out, and buy some DVD Boxsets.
3 seasons of Stargate, 3 of House, 3 of Heroes, and 3 of Smallville.

You also have a pile of shelves.
Now, if you put 1 show onto each shelf, that's 4 shelves you need.
But each shelf would have smeg all else on it, and would be a massive waste of the shelfspace.

Instead, you cram all those DVDs onto one shelf. You keep each show together, so you know where they are, and can get them whenever, but now they're all on one shelf, instead of wasting all that space that's around them.

That's pretty much what's happening here.
Rather than having 10 3-bit integers taking up 10*32 bits, you can cram all 10 into a single 32-bit integer.
That's pretty much a 10:1 reduction in memory, and without any actual compression required.

-=-=-
''Load, Next List!''