Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sample program using the new _Files$ function
#13
(02-06-2024, 12:31 AM)eoredson Wrote: @steve: Thanks for the intel!

It seems a Byte would be, of course, a byte, where a signed byte holds 0 to 127 and an unsigned byte would hold 0 to 255 and
an integer would contain 2 bytes.. Obviously there is no bit or nibble. It does not answer my question why you could assign a _bit in the first place.

A byte is a byte.  An integer is 2 bytes.
A bit is just a portion of a byte.

Thing is, think of it like taking a pie and cutting it into 8 slices.   You eat 7 slices, only leaving one behind....  Now, when you put that pie back in the fridge, how much space does that 1/8th take up compared to the whole pie??

It takes up the same dang amount of space!!  That slice of pie is still in the same pie pan!  It's just got 7 slices which are still missing, but the pan it's stored in is the same as always!

That's what a single bit does -- it still takes up that one space inside a byte.

The *only* time it's useful is when you're bit packing.  To think of it in terms of pies, let's say you have:
1 slice of chocolate pie.
1 slice of lemon pie.
2 slices of custard pie.
3 slices of apple pie.
1 slice of cherry pie.

Now, if each of those pies are in their own pie pan, that's going to take up space for 5 pies in your fridge.   Now, if you take all those pieces, arrange them together into one pie pan, you can pack them all together and save some space.

That's basically bit-packing.  Taking multiple bits and storing them in the same byte.   Unfortunately, the only way to do that is to say, "This is a VARIETY PLATTER of pies."  You can't store them as individual pies anymore and call them "Chocolate Pie", "Lemon Pie", "Custard Pie"....

You'd basically have to DIM Variety_Platter(1 TO 8) AS _BIT.  You couldn't DIM Choco AS _Bit, Lemon AS _Bit, Custard AS _Bit...

Array bit packing is the only time you should ever consider using bits.  Otherwise, just use bytes.   (And only consider it for LARGE bit arrys, as otherwise the overhead just isn;t going to be worth it on modern systems.   I've got 128GB of Ram.  Why should I care if I use 3MB for a byte array, rather than 1/8th that amoung for a packed bit array??)
Reply


Messages In This Thread
RE: Sample program using the new _Files$ function - by SMcNeill - 02-06-2024, 12:58 AM



Users browsing this thread: 2 Guest(s)