Posts Tagged boolean

C++ For C# Developers: Part 2 – Primitive Types and Literals

Tags: , , , , ,

The series continues today with our first actual C++ code! Today we’ll start with the absolute fundamentals—primitive types and literals—on which we’ll build through the rest of the series. As basic as this topic sounds, some of it can be pretty shocking when coming from a language like C#.

Read the rest of this article »

4 Comments

From AS3 to C#, Part 14: Built-in Types and Variables

Tags: , , , ,

The language’s built-in types should be trivial, but they’re not. There are a lot of little details overlooked by many programmers. Today’s article continues the series by looking at subtleties found in seemingly-obvious language features like strings and integers. Read on to learn some tricks!

Read the rest of this article »

8 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

How Big Is That Class?

Tags: , , , , , , , ,

When you instantiate one of your classes, how much memory does it use? Today’s article tries out a lot of combinations and counts the bytes used. The conclusion is easy to remember and will give you a solid understanding of how much memory your app is using.

Read the rest of this article »

5 Comments

The Four Vector Classes

Tags: , , , , , , , ,

There are four Vector classes in AS3. It seems like there is only one—Vector—and that it supports generics, but that is only an illusion. Today’s article will do some tests to reveal the implications to your app’s correctness and efficiency.

Read the rest of this article »

3 Comments

Faster Logic With Bitwise Operators

Tags: , , , , ,

Logical operators are necessary in every app, so it’s unfortunate that they are so slow in AS3. That’s why I was happy to see a potential alternative in a recent comment by Skyboy. Today’s article shows you how to do logic faster by avoiding logical operators (e.g. &&) and using their bitwise (e.g. &) operator counterparts instead.

Read the rest of this article »

25 Comments

Explicit Type Conversion

Tags: , , , , , , ,

Five months ago I said I’d talked about explicit type conversion. I hadn’t, really. What I talked about before was type casts. A cast changes the type, not the data. Today, I’m actually going to talk about type conversion and show you the costs of converting between all of your favorite types: int, uint, Number, Boolean, String, and even XML.

Read the rest of this article »

4 Comments

Implicit Type Conversion

Tags: , , , , , ,

I’ve talked before about explicit type conversion and used the function-call style (Type(obj)) and the as keyword to accomplish the task. Today, I’m going to talk about implicit type conversion and use—as implicit would imply—no operators at all!

Read the rest of this article »

6 Comments

String Conversion

Tags: , , , , , , , , , ,

It struck me recently that there are a lot of ways to convert variables of many types to a the String type. The ease of doing this is one of AS3’s strengths over languages where it’s error-prone, possibly insecure, and just plain difficult. The C language is the most obvious example of this and, since then, seemingly every language has enshrined string conversion in ways ranging from global String() functions (AS3) that take any variable to adding toString() to the base Object type (Java, AS3, others). AS3 seems to have chosen “all of the above” and there are now many ways to convert to a string. Below I’ll look at them from a performance standpoint and see if the everyday, run-of-the-mill boring string conversion can be improved by choosing one option over another.

Read the rest of this article »

3 Comments

The Size of Empty

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , ,

I was reminded about the flash.sampler API by Grant Skinner’s recent post about it. While only available in the debug player, it can still tell us some valuable information about what goes on in the release player. Today I’m using the getSize function to find out how much memory overhead various classes impose, even when they are empty.

Read the rest of this article »

15 Comments