Posts Tagged fixed

C++ For C# Developers: Part 37 – Missing Language Features

Tags: , , , , , ,

We’ve covered all the features in the C++ language! Still, C# has some features that are missing from C++. Today we’ll look at those and explore some alternatives to fill these gaps.

Read the rest of this article »

4 Comments

Can Fixed-Point Improve Performance?

Tags: , , , ,

Fixed-point types save memory compared to floating-point types, but can they also improve performance? Today’s article finds out!

Read the rest of this article »

3 Comments

Fixed-Point: Shrink Data Sizes 4x

Tags: , , ,

Floating-point math is fast these days, but fixed-point still has a purpose: we can use it to store real numbers in less than 32 bits. Saving a measly 16 or 24 bits off a float might not sound appealing, but cutting the data size in half or quarter often does when multiplied across large amounts of real numbers. We can shrink downloads, improve load times, save memory, and fit more into the CPU’s data caches. So today we’ll look at storing numbers in fixed-point formats and see how easy it can be to shrink our data!

Read the rest of this article »

4 Comments

IL2CPP Output for C# 7.3: Local functions, fixed, and stackalloc

Tags: , , , ,

Continuing the series, today we’ll dive into local functions, fixed-size buffers, fixed blocks on arbitrary types with GetPinnableReference, and stackalloc initializers to see how they’re all implemented in C++ and what assembly code ends up actually running on the CPU.

Read the rest of this article »

2 Comments

IL2CPP Output for Unsafe Code

Tags: , , , ,

C# has some powerful features like fixed-size buffers, pointers, and unmanaged local variable arrays courtesy of stackalloc. These are deemed “unsafe” since they all deal with unmanaged memory. We should know what we’re ultimately instructing the CPU to execute when we use these features, so today we’ll take a look at the C++ output from IL2CPP and the assembly output from the C++ compiler to find out just that.

Read the rest of this article »

6 Comments

Optimizing Arrays and Lists

Tags: , , , ,

Last week’s article compared the performance of arrays with List<T> and found List lacking. This week we’ll optimize both List and array to maximize performance regardless of which you choose to use.

Read the rest of this article »

6 Comments

From AS3 to C#, Part 21: Unsafe Code

Tags: , , , ,

The series is nearing an end! In today’s article we’ll cover so-called “unsafe” code that gives you unprecedented access to system memory. You can use this to optimize your app or integrate with native (e.g. C, C++) code and APIs. Read on to learn more about this powerful C# tool!

Read the rest of this article »

4 Comments