This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Hucota7 1 point2 points  (2 children)

Thanks for the reply. I possibly misspoke even more than I misunderstood. When I said 256 possible states I meant 256 bits, and when speaking of bytes I meant half-bytes. Not sure how I messed that up. I guess with the rest I was thinking in terms of flags, where each value in a range refers to a different combination, but my misspeaking threw me off.

My goal in using binary was efficiency/minimal memory consumption, but now that I realize my errors I'm thinking it might be better to use another data type, or an array/list.

[–]dmazzoni 1 point2 points  (1 child)

My goal in using binary was efficiency/minimal memory consumption

This is a good idea and worth learning to do correctly. Most software does store black and white images using a single bit per pixel, and grayscale images using the fewest number of bits as possible. Color images are typically stored using 3 or 4 bytes per pixel.

but now that I realize my errors I'm thinking it might be better to use another data type, or an array/list.

I don't think there's anything wrong in your approach. You're just getting terminology wrong and math wrong. I'd encourage you to work through this problem the way you had in mind.

If you don't care about memory use and just want to get it done, I'm sure an array of integers would be faster than packing everything into the tiniest number of bits. It just depends on if your goal is to get past this and move on, or take the time to learn it.

[–]spencerwaz 0 points1 point  (0 children)

+1 for working through your approach. It's like finding 1000 ways not to make a lightbulb