Posts Tagged bit field

C++ For C# Developers: Part 10 – Struct Basics

Tags: , ,

Let’s continue the series today by starting to look at structs. These are far more powerful in C++ than in C#, so today we’ll start with basics like defining and initializing them. Read on to get started!

Read the rest of this article »

4 Comments

Adding Bit Fields to C#

Tags: ,

Bit fields give us the ability to use less than one byte to store an integer. This can be really useful to fit more data into a CPU cache or to reduce memory usage in general. Unfortunately, bit fields aren’t built into C#. Today we’ll work around that by creating our own!

Read the rest of this article »

6 Comments

BitArray32 and BitArray64

Tags: , , , ,

C# already has two bit array types, but both are lacking. BitArray is a class so it requires heap allocation and GC. BitVector32 is a struct, but it’s usage is bizzare, it’s implemented inefficiently, it’s not enumerable, and there’s no 64-bit version. Today we’ll create a new, simple type to remedy these issues and add a new tool to our toolbox!

Read the rest of this article »

6 Comments

Get More out of Four Bytes than a Boolean

Tags: , ,

A Boolean in AS3 takes up four bytes of memory to store a single bit of information. It takes up 32x more memory than it needs. We can make better use of this memory and today’s article explains how.

Read the rest of this article »

2 Comments